Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e2f7f01a
Commit
e2f7f01a
authored
May 22, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Jun 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notepad: Avoid using pointer value after free.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
parent
7b449063
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
main.c
programs/notepad/main.c
+18
-14
No files found.
programs/notepad/main.c
View file @
e2f7f01a
...
...
@@ -377,10 +377,9 @@ static LPWSTR NOTEPAD_StrRStr(LPWSTR pszSource, LPWSTR pszLast, LPWSTR pszSrch)
void
NOTEPAD_DoFind
(
FINDREPLACEW
*
fr
)
{
LPWSTR
content
;
LPWSTR
found
;
int
len
=
lstrlenW
(
fr
->
lpstrFindWhat
);
int
fileLen
;
DWORD
pos
;
SIZE_T
pos
;
fileLen
=
GetWindowTextLengthW
(
Globals
.
hEdit
)
+
1
;
content
=
HeapAlloc
(
GetProcessHeap
(),
0
,
fileLen
*
sizeof
(
WCHAR
));
...
...
@@ -391,30 +390,34 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr)
switch
(
fr
->
Flags
&
(
FR_DOWN
|
FR_MATCHCASE
))
{
case
0
:
found
=
StrRStrIW
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
);
pos
=
StrRStrIW
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
case
FR_DOWN
:
found
=
StrStrIW
(
content
+
pos
,
fr
->
lpstrFindWhat
);
pos
=
StrStrIW
(
content
+
pos
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
case
FR_MATCHCASE
:
found
=
NOTEPAD_StrRStr
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
);
pos
=
NOTEPAD_StrRStr
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
case
FR_DOWN
|
FR_MATCHCASE
:
found
=
StrStrW
(
content
+
pos
,
fr
->
lpstrFindWhat
);
pos
=
StrStrW
(
content
+
pos
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
default:
/* shouldn't happen */
return
;
}
HeapFree
(
GetProcessHeap
(),
0
,
content
);
if
(
found
==
NULL
)
if
(
pos
==
~
(
SIZE_T
)
0
)
{
DIALOG_StringMsgBox
(
Globals
.
hFindReplaceDlg
,
STRING_NOTFOUND
,
fr
->
lpstrFindWhat
,
MB_ICONINFORMATION
|
MB_OK
);
return
;
}
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
found
-
content
,
found
-
content
+
len
);
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
pos
,
pos
+
len
);
}
static
void
NOTEPAD_DoReplace
(
FINDREPLACEW
*
fr
)
...
...
@@ -452,10 +455,9 @@ static void NOTEPAD_DoReplace(FINDREPLACEW *fr)
static
void
NOTEPAD_DoReplaceAll
(
FINDREPLACEW
*
fr
)
{
LPWSTR
content
;
LPWSTR
found
;
int
len
=
lstrlenW
(
fr
->
lpstrFindWhat
);
int
fileLen
;
DWORD
pos
;
SIZE_T
pos
;
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
0
,
0
);
while
(
TRUE
){
...
...
@@ -468,22 +470,24 @@ static void NOTEPAD_DoReplaceAll(FINDREPLACEW *fr)
switch
(
fr
->
Flags
&
(
FR_DOWN
|
FR_MATCHCASE
))
{
case
FR_DOWN
:
found
=
StrStrIW
(
content
+
pos
,
fr
->
lpstrFindWhat
);
pos
=
StrStrIW
(
content
+
pos
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
case
FR_DOWN
|
FR_MATCHCASE
:
found
=
StrStrW
(
content
+
pos
,
fr
->
lpstrFindWhat
);
pos
=
StrStrW
(
content
+
pos
,
fr
->
lpstrFindWhat
)
-
content
;
if
(
pos
==
-
(
SIZE_T
)
content
)
pos
=
~
(
SIZE_T
)
0
;
break
;
default:
/* shouldn't happen */
return
;
}
HeapFree
(
GetProcessHeap
(),
0
,
content
);
if
(
found
==
NULL
)
if
(
pos
==
~
(
SIZE_T
)
0
)
{
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
0
,
0
);
return
;
}
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
found
-
content
,
found
-
content
+
len
);
SendMessageW
(
Globals
.
hEdit
,
EM_SETSEL
,
pos
,
pos
+
len
);
SendMessageW
(
Globals
.
hEdit
,
EM_REPLACESEL
,
TRUE
,
(
LPARAM
)
fr
->
lpstrReplaceWith
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment