< prev index next >
src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp
Print this page
rev 52446 : 8213532: add missing LocalFree calls after using FormatMessage(A) [windows]
@@ -249,22 +249,28 @@
#ifdef _DEBUG
if (hres != 0) {
DWORD lastError = GetLastError();
if (lastError != 0) {
LPSTR msgBuffer = NULL;
- FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ DWORD fret= FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
lastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msgBuffer,
// it's an output parameter when allocate buffer is used
0,
NULL);
+ if (fret != 0) {
DTRACE_PRINTLN3("Error: hres=0x%x lastError=0x%x %s\n", hres,
lastError, msgBuffer);
+ LocalFree(msgBuffer);
+ } else {
+ DTRACE_PRINTLN3("Error: hres=0x%x lastError=0x%x \n", hres,
+ lastError);
+ }
}
}
#endif
}
< prev index next >