changeset 7384:f695f447f6b7

8014307: Memory leak ... security/jgss/wrapper/GSSLibStub.c Summary: I modified the native procedure: Java_sun_security_jgss_wrapper_GSSLibStub_initContext() so that allocated memory is freed when errors occur. Reviewed-by: chegar, valeriep
author jzavgren
date Fri, 14 Jun 2013 09:13:03 -0400
parents 42f9ad39bf42
children 45a3584bfacf
files src/share/native/sun/security/jgss/wrapper/GSSLibStub.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c	Thu Jun 13 17:48:11 2013 -0700
+++ b/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c	Fri Jun 14 09:13:03 2013 -0400
@@ -329,6 +329,8 @@
   initGSSBuffer(env, jnameVal, &nameVal);
   nameType = newGSSOID(env, jnameType);
   if ((*env)->ExceptionCheck(env)) {
+    deleteGSSOID(nameType);
+    resetGSSBuffer(env, jnameVal, &nameVal);
     return jlong_zero;
   }
 
@@ -823,6 +825,7 @@
                                         FID_NativeGSSContext_lifetime));
   cb = getGSSCB(env, jcb);
   if ((*env)->ExceptionCheck(env)) {
+    free(cb);
     return NULL;
   }
 
@@ -927,6 +930,8 @@
   initGSSBuffer(env, jinToken, &inToken);
   cb = getGSSCB(env, jcb);
   if ((*env)->ExceptionCheck(env)) {
+    free(cb);
+    resetGSSBuffer(env, jinToken, &inToken);
     return NULL;
   }
   srcName = GSS_C_NO_NAME;
@@ -979,6 +984,7 @@
 
       /* return immediately if an exception has occurred */
       if ((*env)->ExceptionCheck(env)) {
+        resetGSSBuffer(env, jinToken, &inToken);
         return NULL;
       }
       sprintf(debugBuf, "[GSSLibStub_acceptContext] set targetName=%ld",
@@ -993,6 +999,7 @@
                                    ptr_to_jlong(srcName), jobj);
       /* return immediately if an exception has occurred */
       if ((*env)->ExceptionCheck(env)) {
+        resetGSSBuffer(env, jinToken, &inToken);
         return NULL;
       }
       sprintf(debugBuf, "[GSSLibStub_acceptContext] set srcName=%ld",
@@ -1019,6 +1026,7 @@
                                      ptr_to_jlong(delCred), jsrcName, jMech);
         /* return immediately if an exception has occurred */
         if ((*env)->ExceptionCheck(env)) {
+          resetGSSBuffer(env, jinToken, &inToken);
           return NULL;
         }
         (*env)->SetObjectField(env, jcontextSpi,