plug memory leak in GetErrorMessage
This commit is contained in:
parent
5cd9bfd25e
commit
0532dd1e1d
|
@ -32,6 +32,7 @@ JNIEXPORT jstring SIGAR_JNI(win32_Win32_GetErrorMessage)
|
||||||
(JNIEnv *env, jclass cls, jint error)
|
(JNIEnv *env, jclass cls, jint error)
|
||||||
{
|
{
|
||||||
LPTSTR msg;
|
LPTSTR msg;
|
||||||
|
jstring str;
|
||||||
|
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS|
|
FORMAT_MESSAGE_IGNORE_INSERTS|
|
||||||
|
@ -39,7 +40,9 @@ JNIEXPORT jstring SIGAR_JNI(win32_Win32_GetErrorMessage)
|
||||||
NULL, error,
|
NULL, error,
|
||||||
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||||
(LPTSTR)&msg, 0, NULL);
|
(LPTSTR)&msg, 0, NULL);
|
||||||
return JENV->NewString(env, (const jchar *)msg, lstrlen(msg));
|
str = JENV->NewString(env, (const jchar *)msg, lstrlen(msg));
|
||||||
|
LocalFree(msg);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue