plug memory leak in GetErrorMessage

This commit is contained in:
Doug MacEachern 2005-06-26 00:52:03 +00:00
parent 5cd9bfd25e
commit 0532dd1e1d
1 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,7 @@ JNIEXPORT jstring SIGAR_JNI(win32_Win32_GetErrorMessage)
(JNIEnv *env, jclass cls, jint error)
{
LPTSTR msg;
jstring str;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_IGNORE_INSERTS|
@ -39,7 +40,9 @@ JNIEXPORT jstring SIGAR_JNI(win32_Win32_GetErrorMessage)
NULL, error,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(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