changeset 9250:e6132f4b6059

8025669: [parfait] warning from b62 for jdk.src.solaris.native.com.sun.security.auth.module: memory leak Reviewed-by: alanb, chegar
author vinnie
date Wed, 05 Feb 2014 18:37:42 +0000
parents f3a403f925e6
children 5db1742d044f 4111af6151ed
files src/solaris/native/com/sun/security/auth/module/Solaris.c
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/com/sun/security/auth/module/Solaris.c	Wed Feb 05 10:21:18 2014 -0800
+++ b/src/solaris/native/com/sun/security/auth/module/Solaris.c	Wed Feb 05 18:37:42 2014 +0000
@@ -75,11 +75,12 @@
         if (fid == 0) {
             (*env)->ExceptionClear(env);
             throwIllegalArgumentException(env, "invalid field: username");
-            return;
+            goto cleanupAndReturn;
         }
         jstr = (*env)->NewStringUTF(env, pwd.pw_name);
-        if (jstr == NULL)
-            return;
+        if (jstr == NULL) {
+            goto cleanupAndReturn;
+        }
         (*env)->SetObjectField(env, obj, fid, jstr);
 
         /*
@@ -89,7 +90,7 @@
         if (fid == 0) {
             (*env)->ExceptionClear(env);
             throwIllegalArgumentException(env, "invalid field: uid");
-            return;
+            goto cleanupAndReturn;
         }
         (*env)->SetLongField(env, obj, fid, pwd.pw_uid);
 
@@ -100,7 +101,7 @@
         if (fid == 0) {
             (*env)->ExceptionClear(env);
             throwIllegalArgumentException(env, "invalid field: gid");
-            return;
+            goto cleanupAndReturn;
         }
         (*env)->SetLongField(env, obj, fid, pwd.pw_gid);
 
@@ -111,19 +112,24 @@
         if (fid == 0) {
             (*env)->ExceptionClear(env);
             throwIllegalArgumentException(env, "invalid field: groups");
-            return;
+            goto cleanupAndReturn;
         }
 
         jgroups = (*env)->NewLongArray(env, numSuppGroups);
-        if (jgroups == NULL)
-            return;
+        if (jgroups == NULL) {
+            goto cleanupAndReturn;
+        }
         jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0);
-        if (jgroupsAsArray == NULL)
-            return;
+        if (jgroupsAsArray == NULL) {
+            goto cleanupAndReturn;
+        }
         for (i = 0; i < numSuppGroups; i++)
             jgroupsAsArray[i] = groups[i];
         (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0);
         (*env)->SetObjectField(env, obj, fid, jgroups);
     }
+cleanupAndReturn:
+    free(groups);
+
     return;
 }