8215411: some GetByteArrayElements calls miss corresponding Release

Reviewed-by: dholmes, jcbeyler
This commit is contained in:
Matthias Baesken 2018-12-19 10:30:43 +01:00
parent 556d79b518
commit e4b1f82bbd
3 changed files with 18 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -578,13 +578,15 @@ JNF_COCOA_ENTER(env);
cssmPerror("_addItemToKeychain: SecKeychainItemImport", err);
}
(*env)->ReleaseByteArrayElements(env, rawDataObj, rawData, JNI_ABORT);
if (createdItems != NULL) {
CFRelease(createdItems);
}
errOut:
if (rawData) {
(*env)->ReleaseByteArrayElements(env, rawDataObj, rawData, JNI_ABORT);
}
if (passwordStrRef) CFRelease(passwordStrRef);
if (passwordChars) {
// clear the password and release

View File

@ -457,12 +457,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue
if (pCode == NULL) {
JNU_ThrowIOExceptionWithLastError(env, "VirtualAllocEx failed");
VirtualFreeEx(hProcess, pData, 0, MEM_RELEASE);
(*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT);
return;
}
WriteProcessMemory( hProcess, (LPVOID)pCode, (LPCVOID)stubCode, (SIZE_T)stubLen, NULL );
if (isCopy) {
(*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT);
}
(*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT);
/*
* Create thread in target process to execute code

View File

@ -722,19 +722,25 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebugger
IDebugDataSpaces* ptrIDebugDataSpaces = (IDebugDataSpaces*) env->GetLongField(obj,
ptrIDebugDataSpaces_ID);
CHECK_EXCEPTION_(0);
if (env->ExceptionOccurred()) {
env->ReleaseByteArrayElements(byteArray, bytePtr, JNI_ABORT);
return 0;
}
ULONG bytesRead;
if (ptrIDebugDataSpaces->ReadVirtual((ULONG64) address, (PVOID) bytePtr,
(ULONG)numBytes, &bytesRead) != S_OK) {
THROW_NEW_DEBUGGER_EXCEPTION_("Windbg Error: ReadVirtual failed!", 0);
}
if (bytesRead != numBytes) {
env->ReleaseByteArrayElements(byteArray, bytePtr, JNI_ABORT);
throwNewDebuggerException(env, "Windbg Error: ReadVirtual failed!");
return 0;
}
if (bytesRead != numBytes) {
env->ReleaseByteArrayElements(byteArray, bytePtr, JNI_ABORT);
return 0;
}
env->ReleaseByteArrayElements(byteArray, bytePtr, 0);
CHECK_EXCEPTION_(0);
return byteArray;