OpenJDK / jdk / jdk
changeset 37804:3d485fe01521
8155211: Ucrypto Library leaks native memory
Summary: Free the memory allocated by calloc(0, x) calls
Reviewed-by: valeriep, igerasim
author | stuefe |
---|---|
date | Sat, 07 May 2016 00:26:02 +0000 |
parents | ac955d7f5271 |
children | de13122a9255 |
files | jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c |
diffstat | 1 files changed, 9 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c Fri May 06 14:03:08 2016 -0700 +++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c Sat May 07 00:26:02 2016 +0000 @@ -650,6 +650,7 @@ unsigned char *bufIn; unsigned char *bufOut; int outLen, rv = 0; + jint rc; context = (crypto_ctx_t *) contextID; @@ -668,22 +669,20 @@ } rv = CipherFinal(context, encrypt, bufOut, 0, &outLen); if (rv) { - free(context); - if (outLen != 0) { - free(bufOut); - } - return -rv; + rc = -rv; } else { - if (bufOut != NULL && outLen != 0) { + if (outLen > 0) { (*env)->SetByteArrayRegion(env, out, outOfs, outLen, (jbyte *)bufOut); - free(bufOut); } - free(context); - return outLen; + rc = outLen; } + free(context); + if (bufOut != (unsigned char *)(&outLen)) { + free(bufOut); + } + return rc; } - /* * Class: com_oracle_security_ucrypto_NativeKey * Method: nativeFree