< prev index next >

src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c

Print this page
rev 14307 : 8155211: Ucrypto Library leaks native memory
Reviewed-by:

*** 648,657 **** --- 648,658 ---- jbyteArray out, jint outOfs) { crypto_ctx_t *context; unsigned char *bufIn; unsigned char *bufOut; int outLen, rv = 0; + jint rc; context = (crypto_ctx_t *) contextID; // out is null when nativeFinal() is called solely for resource clean up if (out == NULL) {
*** 666,691 **** return 0; } } rv = CipherFinal(context, encrypt, bufOut, 0, &outLen); if (rv) { ! free(context); ! if (outLen != 0) { ! free(bufOut); ! } ! return -rv; } else { ! if (bufOut != NULL && outLen != 0) { (*env)->SetByteArrayRegion(env, out, outOfs, outLen, (jbyte *)bufOut); ! free(bufOut); } free(context); ! return outLen; } } - /* * Class: com_oracle_security_ucrypto_NativeKey * Method: nativeFree * Signature: (JI)V */ --- 667,690 ---- return 0; } } rv = CipherFinal(context, encrypt, bufOut, 0, &outLen); if (rv) { ! rc = -rv; } else { ! if (outLen > 0) { (*env)->SetByteArrayRegion(env, out, outOfs, outLen, (jbyte *)bufOut); ! } ! rc = outLen; } free(context); ! if (bufOut != (unsigned char *)(&outLen)) { ! free(bufOut); } + return rc; } /* * Class: com_oracle_security_ucrypto_NativeKey * Method: nativeFree * Signature: (JI)V */
< prev index next >