Gabriel Ivăncescu : notepad: Fix uninitialized upper 64-bits of `pos` in DoFind.
Module: wine Branch: master Commit: 929fdbbf5541d0139492b6e5072e0cb410073776 URL: https://gitlab.winehq.org/wine/wine/-/commit/929fdbbf5541d0139492b6e5072e0cb... Author: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Date: Wed Jan 18 18:30:14 2023 +0200 notepad: Fix uninitialized upper 64-bits of `pos` in DoFind. And get rid of the hacky casts. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- programs/notepad/main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/programs/notepad/main.c b/programs/notepad/main.c index 930884d144f..829cd7af33b 100644 --- a/programs/notepad/main.c +++ b/programs/notepad/main.c @@ -441,10 +441,10 @@ static LPWSTR NOTEPAD_StrRStr(LPWSTR pszSource, LPWSTR pszLast, LPWSTR pszSrch) */ void NOTEPAD_DoFind(FINDREPLACEW *fr) { - LPWSTR content; + LPWSTR content, found; int len = lstrlenW(fr->lpstrFindWhat); int fileLen; - SIZE_T pos; + DWORD pos; fileLen = GetWindowTextLengthW(Globals.hEdit) + 1; content = HeapAlloc(GetProcessHeap(), 0, fileLen * sizeof(WCHAR)); @@ -455,27 +455,24 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr) switch (fr->Flags & (FR_DOWN|FR_MATCHCASE)) { case 0: - pos = StrRStrIW(content, content+pos-len, fr->lpstrFindWhat) - content; - if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0; + found = StrRStrIW(content, content+pos-len, fr->lpstrFindWhat); break; case FR_DOWN: - pos = StrStrIW(content+pos, fr->lpstrFindWhat) - content; - if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0; + found = StrStrIW(content+pos, fr->lpstrFindWhat); break; case FR_MATCHCASE: - pos = NOTEPAD_StrRStr(content, content+pos-len, fr->lpstrFindWhat) - content; - if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0; + found = NOTEPAD_StrRStr(content, content+pos-len, fr->lpstrFindWhat); break; case FR_DOWN|FR_MATCHCASE: - pos = StrStrW(content+pos, fr->lpstrFindWhat) - content; - if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0; + found = StrStrW(content+pos, fr->lpstrFindWhat); break; default: /* shouldn't happen */ return; } + pos = found - content; HeapFree(GetProcessHeap(), 0, content); - if (pos == ~(SIZE_T)0) + if (!found) { DIALOG_StringMsgBox(Globals.hFindReplaceDlg, STRING_NOTFOUND, fr->lpstrFindWhat, MB_ICONINFORMATION|MB_OK);
participants (1)
-
Alexandre Julliard