From e69d05f1b4ec83b91c2a751952a3339597c332ff Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 29 Aug 2020 07:02:19 +0200 Subject: [PATCH] + fix: buffer to small in case of auto-esc ctrl-chars in find/replace edit-control --- src/Edit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 5b36a536c..0bc24cfab 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5966,16 +5966,17 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd,UINT umsg,WPARAM wParam DocPos const cchSelection = SciCall_GetSelText(NULL); if ((1 < cchSelection) && (LOWORD(wParam) != IDC_REPLACETEXT)) { - lpszSelection = AllocMem(cchSelection + 1, HEAP_ZERO_MEMORY); if (sg_pefrData->bAutoEscCtrlChars) { + lpszSelection = AllocMem((cchSelection<<1) + 1, HEAP_ZERO_MEMORY); char* buf = AllocMem(cchSelection + 1, HEAP_ZERO_MEMORY); if (buf) { SciCall_GetSelText(buf); - SlashA(lpszSelection, cchSelection, buf); + SlashA(lpszSelection, (cchSelection<<1), buf); FreeMem(buf); } } else { + lpszSelection = AllocMem(cchSelection + 1, HEAP_ZERO_MEMORY); SciCall_GetSelText(lpszSelection); } } @@ -5993,11 +5994,12 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd,UINT umsg,WPARAM wParam if (pClip) { size_t const len = StringCchLenA(pClip, 0); if (len) { - lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY); if (sg_pefrData->bAutoEscCtrlChars) { - SlashA(lpszSelection, len + 1, pClip); + lpszSelection = AllocMem((len<<1) + 1, HEAP_ZERO_MEMORY); + SlashA(lpszSelection, (len<<1) + 1, pClip); } else { + lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY); StringCchCopyA(lpszSelection, len + 1, pClip); } }