8025669: [parfait] warning from b62 for jdk.src.solaris.native.com.sun.security.auth.module: memory leak
authorvinnie
Wed, 05 Feb 2014 18:37:42 +0000
changeset 22658 30164afa0211
parent 22657 654c573cb341
child 22659 4a4630af7adf
child 22934 705df2581571
8025669: [parfait] warning from b62 for jdk.src.solaris.native.com.sun.security.auth.module: memory leak Reviewed-by: alanb, chegar
jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c
--- a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c	Wed Feb 05 10:21:18 2014 -0800
+++ b/jdk/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;
 }