Commit 929fdbbf authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

notepad: Fix uninitialized upper 64-bits of `pos` in DoFind.

And get rid of the hacky casts. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent 8ddf8daa
...@@ -441,10 +441,10 @@ static LPWSTR NOTEPAD_StrRStr(LPWSTR pszSource, LPWSTR pszLast, LPWSTR pszSrch) ...@@ -441,10 +441,10 @@ static LPWSTR NOTEPAD_StrRStr(LPWSTR pszSource, LPWSTR pszLast, LPWSTR pszSrch)
*/ */
void NOTEPAD_DoFind(FINDREPLACEW *fr) void NOTEPAD_DoFind(FINDREPLACEW *fr)
{ {
LPWSTR content; LPWSTR content, found;
int len = lstrlenW(fr->lpstrFindWhat); int len = lstrlenW(fr->lpstrFindWhat);
int fileLen; int fileLen;
SIZE_T pos; DWORD pos;
fileLen = GetWindowTextLengthW(Globals.hEdit) + 1; fileLen = GetWindowTextLengthW(Globals.hEdit) + 1;
content = HeapAlloc(GetProcessHeap(), 0, fileLen * sizeof(WCHAR)); content = HeapAlloc(GetProcessHeap(), 0, fileLen * sizeof(WCHAR));
...@@ -455,27 +455,24 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr) ...@@ -455,27 +455,24 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr)
switch (fr->Flags & (FR_DOWN|FR_MATCHCASE)) switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
{ {
case 0: case 0:
pos = StrRStrIW(content, content+pos-len, fr->lpstrFindWhat) - content; found = StrRStrIW(content, content+pos-len, fr->lpstrFindWhat);
if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0;
break; break;
case FR_DOWN: case FR_DOWN:
pos = StrStrIW(content+pos, fr->lpstrFindWhat) - content; found = StrStrIW(content+pos, fr->lpstrFindWhat);
if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0;
break; break;
case FR_MATCHCASE: case FR_MATCHCASE:
pos = NOTEPAD_StrRStr(content, content+pos-len, fr->lpstrFindWhat) - content; found = NOTEPAD_StrRStr(content, content+pos-len, fr->lpstrFindWhat);
if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0;
break; break;
case FR_DOWN|FR_MATCHCASE: case FR_DOWN|FR_MATCHCASE:
pos = StrStrW(content+pos, fr->lpstrFindWhat) - content; found = StrStrW(content+pos, fr->lpstrFindWhat);
if (pos == -(SIZE_T)content) pos = ~(SIZE_T)0;
break; break;
default: /* shouldn't happen */ default: /* shouldn't happen */
return; return;
} }
pos = found - content;
HeapFree(GetProcessHeap(), 0, content); HeapFree(GetProcessHeap(), 0, content);
if (pos == ~(SIZE_T)0) if (!found)
{ {
DIALOG_StringMsgBox(Globals.hFindReplaceDlg, STRING_NOTFOUND, fr->lpstrFindWhat, DIALOG_StringMsgBox(Globals.hFindReplaceDlg, STRING_NOTFOUND, fr->lpstrFindWhat,
MB_ICONINFORMATION|MB_OK); MB_ICONINFORMATION|MB_OK);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment