8213532: add missing LocalFree calls after using FormatMessage(A) [windows]
Reviewed-by: dmarkov, serb
This commit is contained in:
parent
4ed24b2a03
commit
faae1772c1
@ -251,7 +251,7 @@ static void assert_result(HRESULT hres, JNIEnv *env) {
|
|||||||
DWORD lastError = GetLastError();
|
DWORD lastError = GetLastError();
|
||||||
if (lastError != 0) {
|
if (lastError != 0) {
|
||||||
LPSTR msgBuffer = NULL;
|
LPSTR msgBuffer = NULL;
|
||||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
DWORD fret= FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
NULL,
|
NULL,
|
||||||
@ -261,8 +261,14 @@ static void assert_result(HRESULT hres, JNIEnv *env) {
|
|||||||
// it's an output parameter when allocate buffer is used
|
// it's an output parameter when allocate buffer is used
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
DTRACE_PRINTLN3("Error: hres=0x%x lastError=0x%x %s\n", hres,
|
if (fret != 0) {
|
||||||
|
DTRACE_PRINTLN3("Error: hres=0x%x lastError=0x%x %s\n", hres,
|
||||||
lastError, msgBuffer);
|
lastError, msgBuffer);
|
||||||
|
LocalFree(msgBuffer);
|
||||||
|
} else {
|
||||||
|
DTRACE_PRINTLN2("Error: hres=0x%x lastError=0x%x \n", hres,
|
||||||
|
lastError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -182,7 +182,7 @@ void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int l
|
|||||||
int ret = IDNO;
|
int ret = IDNO;
|
||||||
static jboolean headless = isHeadless();
|
static jboolean headless = isHeadless();
|
||||||
|
|
||||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
DWORD fret= FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
NULL,
|
NULL,
|
||||||
@ -197,7 +197,9 @@ void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int l
|
|||||||
}
|
}
|
||||||
// format the assertion message
|
// format the assertion message
|
||||||
_snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
|
_snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
|
||||||
LocalFree(msgBuffer);
|
if (fret != 0) {
|
||||||
|
LocalFree(msgBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
// tell the user the bad news
|
// tell the user the bad news
|
||||||
fprintf(stderr, "*********************\n");
|
fprintf(stderr, "*********************\n");
|
||||||
|
@ -66,6 +66,7 @@ char *printError(char *msg) {
|
|||||||
if (lpMsgBuf != NULL) {
|
if (lpMsgBuf != NULL) {
|
||||||
strncat((char *)retbuf, ": ", sizeof(retbuf) - strlen(retbuf) - 1);
|
strncat((char *)retbuf, ": ", sizeof(retbuf) - strlen(retbuf) - 1);
|
||||||
strncat((char *)retbuf, (char *)lpMsgBuf, sizeof(retbuf) - strlen(retbuf) - 1);
|
strncat((char *)retbuf, (char *)lpMsgBuf, sizeof(retbuf) - strlen(retbuf) - 1);
|
||||||
|
LocalFree(lpMsgBuf);
|
||||||
}
|
}
|
||||||
return (char *)retbuf;
|
return (char *)retbuf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user