Fix possible heap memory leak

Close #16883
This commit is contained in:
xomx 2025-07-30 19:59:55 +02:00 committed by Don Ho
parent c367ab8966
commit c710439b51
4 changed files with 14 additions and 5 deletions

View File

@ -360,6 +360,7 @@ void HashFromTextDlg::generateHash()
break; break;
default: default:
delete[] text;
return; return;
} }
@ -444,6 +445,7 @@ void HashFromTextDlg::generateHashPerLine()
break; break;
default: default:
delete[] text;
return; return;
} }

View File

@ -471,6 +471,8 @@ void Notepad_plus::command(int id)
::GlobalUnlock(hglbCopy); ::GlobalUnlock(hglbCopy);
pBinText.reset(nullptr); // free possible big membuf ASAP
// Place the handle on the clipboard. // Place the handle on the clipboard.
if (!::SetClipboardData(CF_TEXT, hglbCopy)) if (!::SetClipboardData(CF_TEXT, hglbCopy))
{ {
@ -3477,6 +3479,7 @@ void Notepad_plus::command(int id)
break; break;
default: default:
delete[] selectedStr;
return; return;
} }
for (int i = 0; i < hashLen; i++) for (int i = 0; i < hashLen; i++)

View File

@ -3061,6 +3061,7 @@ bool FindReplaceDlg::processFindNext(const wchar_t *txt2find, const FindOption *
else if (posFind == FIND_INVALID_REGULAR_EXPRESSION) else if (posFind == FIND_INVALID_REGULAR_EXPRESSION)
{ // error { // error
setStatusbarMessageWithRegExprErr(*_ppEditView); setStatusbarMessageWithRegExprErr(*_ppEditView);
delete[] pText;
return false; return false;
} }
@ -3656,6 +3657,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
default: default:
{ {
delete[] pTextFind; delete[] pTextFind;
if (pTextReplace)
delete[] pTextReplace; delete[] pTextReplace;
return nbProcessed; return nbProcessed;
} }
@ -3673,6 +3675,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
} }
delete[] pTextFind; delete[] pTextFind;
if (pTextReplace)
delete[] pTextReplace; delete[] pTextReplace;
if (nbProcessed > 0) if (nbProcessed > 0)

View File

@ -295,6 +295,7 @@ intptr_t CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam
catch (...) catch (...)
{ {
MessageBox(_hSelf, L"Cannot process this clipboard data in the history:\nThe data is too large to be treated.", L"Clipboard problem", MB_OK | MB_APPLMODAL); MessageBox(_hSelf, L"Cannot process this clipboard data in the history:\nThe data is too large to be treated.", L"Clipboard problem", MB_OK | MB_APPLMODAL);
if (c)
delete[] c; delete[] c;
} }
} }