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
35c8f15b
Commit
35c8f15b
authored
Jun 12, 2023
by
Fabian Maurer
Committed by
Alexandre Julliard
Jul 05, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Ignore invalid parameters in DrawTextEx when HDC is invalid.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=47089
Signed-off-by:
Fabian Maurer
<
dark.shadow4@web.de
>
parent
9f9f799a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
5 deletions
+48
-5
text.c
dlls/user32/tests/text.c
+32
-0
text.c
dlls/user32/text.c
+16
-5
No files found.
dlls/user32/tests/text.c
View file @
35c8f15b
...
...
@@ -519,6 +519,38 @@ static void test_DrawTextCalcRect(void)
ok
(
textheight
==
0
,
"Got textheight from DrawTextExW
\n
"
);
ok
(
dtp
.
uiLengthDrawn
==
1337
,
"invalid dtp.uiLengthDrawn = %i
\n
"
,
dtp
.
uiLengthDrawn
);
}
/* When passing invalid DC, other parameters must be ignored - no crashes on invalid pointers */
SetLastError
(
0xdeadbeef
);
textheight
=
DrawTextExW
((
HDC
)
0xdeadbeef
,
emptystringW
,
100000
,
(
LPRECT
)
0xdeadbeef
,
0
,
0
);
ok
(
textheight
==
0
,
"Got textheight from DrawTextExW
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
textheight
=
DrawTextExW
((
HDC
)
0xdeadbeef
,
(
LPWSTR
)
0xdeadbeef
,
100000
,
&
rect
,
0
,
0
);
ok
(
textheight
==
0
,
"Got textheight from DrawTextExW
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
textheight
=
DrawTextExW
((
HDC
)
0xdeadbeef
,
0
,
-
1
,
(
LPRECT
)
0xdeadbeef
,
DT_CALCRECT
,
0
);
ok
(
textheight
==
0
,
"Got textheight from DrawTextExW
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
textheight
=
DrawTextExA
((
HDC
)
0xdeadbeef
,
emptystring
,
100000
,
(
LPRECT
)
0xdeadbeef
,
0
,
0
);
ok
(
textheight
==
0
,
"Got textheight from DrawTextExA
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Got error %lu
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
textheight
=
DrawTextExA
((
HDC
)
0xdeadbeef
,
0
,
-
1
,
(
LPRECT
)
0xdeadbeef
,
DT_CALCRECT
,
0
);
ok
(
textheight
==
0
,
"Got textheight from DrawTextExA
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Got error %lu
\n
"
,
GetLastError
());
if
(
0
)
{
/* Crashes */
textheight
=
DrawTextExA
((
HDC
)
0xdeadbeef
,
(
LPSTR
)
0xdeadbeef
,
100
,
&
rect
,
0
,
0
);
}
}
/* More test cases from bug 12226 */
...
...
dlls/user32/text.c
View file @
35c8f15b
...
...
@@ -874,8 +874,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
int
len
,
lh
,
count
=
i_count
;
TEXTMETRICW
tm
;
int
lmargin
=
0
,
rmargin
=
0
;
int
x
=
rect
->
left
,
y
=
rect
->
top
;
int
width
=
rect
->
right
-
rect
->
left
;
int
x
,
y
,
width
;
int
max_width
=
0
;
int
last_line
;
int
tabwidth
/* to keep gcc happy */
=
0
;
...
...
@@ -897,7 +896,13 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
if
(
flags
&
DT_SINGLELINE
)
flags
&=
~
DT_WORDBREAK
;
GetTextMetricsW
(
hdc
,
&
tm
);
if
(
!
GetTextMetricsW
(
hdc
,
&
tm
))
return
0
;
x
=
rect
->
left
;
y
=
rect
->
top
;
width
=
rect
->
right
-
rect
->
left
;
if
(
flags
&
DT_EXTERNALLEADING
)
lh
=
tm
.
tmHeight
+
tm
.
tmExternalLeading
;
else
...
...
@@ -1086,18 +1091,24 @@ INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
DWORD
wmax
;
DWORD
amax
;
UINT
cp
;
TEXTMETRICA
tm
;
if
(
!
GetTextMetricsA
(
hdc
,
&
tm
))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
0
;
}
if
(
!
count
)
return
0
;
if
(
!
str
&&
count
>
0
)
return
0
;
if
(
!
str
||
((
count
==
-
1
)
&&
!
(
count
=
strlen
(
str
))))
{
int
lh
;
TEXTMETRICA
tm
;
if
(
dtp
&&
dtp
->
cbSize
!=
sizeof
(
DRAWTEXTPARAMS
))
return
0
;
GetTextMetricsA
(
hdc
,
&
tm
);
if
(
flags
&
DT_EXTERNALLEADING
)
lh
=
tm
.
tmHeight
+
tm
.
tmExternalLeading
;
else
...
...
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