changeset 52222:d80d077d65b1

8212216: JGSS: Fix leak in exception cases in getJavaOID() Reviewed-by: mullan, weijun Contributed-by: Nico Williams <nico@twosigma.com>
author weijun
date Tue, 23 Oct 2018 12:25:59 +0800
parents 27ba7cc31f9f
children d0983f073c54
files src/java.security.jgss/share/native/libj2gss/NativeUtil.c
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.security.jgss/share/native/libj2gss/NativeUtil.c	Mon Oct 22 19:31:41 2018 -0700
+++ b/src/java.security.jgss/share/native/libj2gss/NativeUtil.c	Tue Oct 23 12:25:59 2018 +0800
@@ -724,17 +724,14 @@
   if (jbytes == NULL) {
     return NULL;
   }
-  (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr);
-  if ((*env)->ExceptionCheck(env)) {
-    return NULL;
+  if (!(*env)->ExceptionCheck(env)) {
+    (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr);
   }
-  (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements);
-  if ((*env)->ExceptionCheck(env)) {
-    return NULL;
+  if (!(*env)->ExceptionCheck(env)) {
+    (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements);
   }
-  result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes);
-  if ((*env)->ExceptionCheck(env)) {
-    return NULL;
+  if (!(*env)->ExceptionCheck(env)) {
+    result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes);
   }
   (*env)->DeleteLocalRef(env, jbytes);
   return result;