8193262: JNI array not released in libsunmscapi convertToLittleEndian
Reviewed-by: ascarpino
This commit is contained in:
parent
50484af54b
commit
254138139f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1600,11 +1600,15 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus
|
||||
int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination,
|
||||
int destinationLength) {
|
||||
|
||||
int result = -1;
|
||||
jbyte* sourceBytes = NULL;
|
||||
|
||||
__try {
|
||||
int sourceLength = env->GetArrayLength(source);
|
||||
|
||||
jbyte* sourceBytes = env->GetByteArrayElements(source, 0);
|
||||
sourceBytes = env->GetByteArrayElements(source, 0);
|
||||
if (sourceBytes == NULL) {
|
||||
return -1;
|
||||
__leave;
|
||||
}
|
||||
|
||||
int copyLen = sourceLength;
|
||||
@ -1613,7 +1617,7 @@ int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination,
|
||||
if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) {
|
||||
copyLen--;
|
||||
} else {
|
||||
return -1;
|
||||
__leave;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1626,10 +1630,15 @@ int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination,
|
||||
if (copyLen < destinationLength) {
|
||||
memset(destination + copyLen, 0, destinationLength - copyLen);
|
||||
}
|
||||
|
||||
result = destinationLength;
|
||||
} __finally {
|
||||
// Clean up.
|
||||
if (sourceBytes) {
|
||||
env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT);
|
||||
}
|
||||
}
|
||||
|
||||
return destinationLength;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user