mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-2442 fix memory leak of fileBuffer
fix was suggested by Nikita Gubarkov
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
aaee235417
commit
ef7d58a9f4
@@ -627,6 +627,8 @@ AwtFileDialog::Show(void *p)
|
||||
|
||||
peer = (jobject)p;
|
||||
|
||||
LPTSTR fileBuffer = NULL;
|
||||
|
||||
static BOOL useCommonItemDialog = JNU_CallStaticMethodByName(env, NULL,
|
||||
"sun/awt/windows/WFileDialogPeer", "useCommonItemDialog", "()Z").z == JNI_TRUE;
|
||||
try {
|
||||
@@ -673,7 +675,7 @@ AwtFileDialog::Show(void *p)
|
||||
} else {
|
||||
bufferLimit = SINGLE_MODE_BUFFER_LIMIT;
|
||||
}
|
||||
LPTSTR fileBuffer = new TCHAR[bufferLimit];
|
||||
fileBuffer = new TCHAR[bufferLimit];
|
||||
memset(fileBuffer, 0, bufferLimit * sizeof(TCHAR));
|
||||
|
||||
file = (jstring)env->GetObjectField(target, AwtFileDialog::fileID);
|
||||
@@ -878,8 +880,9 @@ AwtFileDialog::Show(void *p)
|
||||
env->DeleteGlobalRef(peer);
|
||||
|
||||
delete[] currentDirectory;
|
||||
if (ofn.lpstrFile)
|
||||
delete[] ofn.lpstrFile;
|
||||
/* ofn.lpstrFile may have not been set if useCommonItemDialog == true,
|
||||
* so use fileBuffer instead */
|
||||
delete[] fileBuffer;
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -898,8 +901,9 @@ AwtFileDialog::Show(void *p)
|
||||
env->DeleteGlobalRef(peer);
|
||||
|
||||
delete[] currentDirectory;
|
||||
if (ofn.lpstrFile)
|
||||
delete[] ofn.lpstrFile;
|
||||
/* ofn.lpstrFile may have not been set if useCommonItemDialog == true,
|
||||
* so use fileBuffer instead */
|
||||
delete[] fileBuffer;
|
||||
}
|
||||
|
||||
BOOL AwtFileDialog::InheritsNativeMouseWheelBehavior() {return true;}
|
||||
|
||||
Reference in New Issue
Block a user