Skip to content

Commit

Permalink
8212216: JGSS: Fix leak in exception cases in getJavaOID()
Browse files Browse the repository at this point in the history
Backport-of: 1002730
  • Loading branch information
GoeLin committed Jan 2, 2023
1 parent 4c2ff08 commit ffc2ced
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/java.security.jgss/share/native/libj2gss/NativeUtil.c
Expand Up @@ -724,17 +724,14 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) {
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;
Expand Down

1 comment on commit ffc2ced

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.