Memory leak fix for: src/solaris/native/com/sun/security/auth/module/Unix.c

Dmitry Samersoff Dmitry.Samersoff at oracle.com
Mon Oct 22 14:18:15 UTC 2012


Chris,

On 2012-10-22 17:11, Chris Hegarty wrote:
> We should simply do:
>     fid = (*env)->GetFieldID(env, cls, "uid", "J");
>     if (fid == 0)
>         goto cleanUpAndReturn;
> 
>  .. and forget the IAE lookup, etc..


I'm second for simple code above if now spec requires IAE here.

Also it's better to retrieve all fields first, before setting any values
as it's good practice to don't modify client data on error.

i.e.

fid_username = (*env)->GetFieldID()
if (fid_username == 0 )
  goto cleanup_and_return;

fid_uid = (*env)->GetFieldID()
if (fid_uid == 0 )
  goto cleanup_and_return;

....

fid_gid = (*env)->GetFieldID()
....

// Set all required fields here

-Dmitry



-- 
Dmitry Samersoff
Java Hotspot development team, SPB04
* There will come soft rains ...



More information about the security-dev mailing list