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;
default:
delete[] text;
return;
}
@ -444,6 +445,7 @@ void HashFromTextDlg::generateHashPerLine()
break;
default:
delete[] text;
return;
}

View File

@ -471,6 +471,8 @@ void Notepad_plus::command(int id)
::GlobalUnlock(hglbCopy);
pBinText.reset(nullptr); // free possible big membuf ASAP
// Place the handle on the clipboard.
if (!::SetClipboardData(CF_TEXT, hglbCopy))
{
@ -3477,6 +3479,7 @@ void Notepad_plus::command(int id)
break;
default:
delete[] selectedStr;
return;
}
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)
{ // error
setStatusbarMessageWithRegExprErr(*_ppEditView);
delete[] pText;
return false;
}
@ -3655,8 +3656,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
default:
{
delete [] pTextFind;
delete [] pTextReplace;
delete[] pTextFind;
if (pTextReplace)
delete[] pTextReplace;
return nbProcessed;
}
@ -3672,8 +3674,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace
}
delete [] pTextFind;
delete [] pTextReplace;
delete[] pTextFind;
if (pTextReplace)
delete[] pTextReplace;
if (nbProcessed > 0)
{

View File

@ -295,7 +295,8 @@ intptr_t CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam
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);
delete[] c;
if (c)
delete[] c;
}
}
}