diff options
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/main/native/org_conscrypt_NativeCrypto.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp b/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp index 9fff02c..62eda3e 100644 --- a/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp +++ b/crypto/src/main/native/org_conscrypt_NativeCrypto.cpp @@ -752,8 +752,7 @@ static jbyteArray bignumToArray(JNIEnv* env, const BIGNUM* source, const char* s return NULL; } - int len = BN_num_bytes(source) + 1; - jbyteArray javaBytes = env->NewByteArray(len); + jbyteArray javaBytes = env->NewByteArray(BN_num_bytes(source) + 1); ScopedByteArrayRW bytes(env, javaBytes); if (bytes.get() == NULL) { JNI_TRACE("bignumToArray(%p, %s) => NULL", source, sourceName); @@ -769,7 +768,7 @@ static jbyteArray bignumToArray(JNIEnv* env, const BIGNUM* source, const char* s *tmp = 0x00; } - if (BN_bn2bin(source, tmp + 1) <= 0) { + if (BN_num_bytes(source) > 0 && BN_bn2bin(source, tmp + 1) <= 0) { throwExceptionIfNecessary(env, "bignumToArray"); return NULL; } |