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
f394bed5
Commit
f394bed5
authored
Oct 15, 2009
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 15, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/tooltips: Test the way structure size field is validated.
parent
98a7d8cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
7 deletions
+150
-7
tooltips.c
dlls/comctl32/tests/tooltips.c
+148
-0
tooltips.c
dlls/comctl32/tooltips.c
+2
-7
No files found.
dlls/comctl32/tests/tooltips.c
View file @
f394bed5
...
...
@@ -23,6 +23,8 @@
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
static
void
test_create_tooltip
(
void
)
{
HWND
parent
,
hwnd
;
...
...
@@ -464,6 +466,152 @@ static void test_ttm_gettoolinfo(void)
ok
(
0xaaaaaaaa
==
ti
.
lParam
,
"Expected 0xaaaaaaaa, got %lx
\n
"
,
ti
.
lParam
);
DestroyWindow
(
hwnd
);
/* 1. test size parameter validation rules (ansi messages) */
hwnd
=
CreateWindowExA
(
0
,
TOOLTIPS_CLASSA
,
NULL
,
0
,
10
,
10
,
300
,
100
,
NULL
,
NULL
,
NULL
,
0
);
ti
.
cbSize
=
TTTOOLINFOA_V1_SIZE
-
1
;
ti
.
hwnd
=
NULL
;
ti
.
hinst
=
GetModuleHandleA
(
NULL
);
ti
.
uFlags
=
0
;
ti
.
uId
=
0x1234ABCD
;
ti
.
lpszText
=
NULL
;
ti
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
ti
.
rect
);
r
=
SendMessage
(
hwnd
,
TTM_ADDTOOLA
,
0
,
(
LPARAM
)
&
ti
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
ti
.
cbSize
=
TTTOOLINFOA_V1_SIZE
-
1
;
ti
.
hwnd
=
NULL
;
ti
.
uId
=
0x1234ABCD
;
SendMessage
(
hwnd
,
TTM_DELTOOLA
,
0
,
(
LPARAM
)
&
ti
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
ti
.
cbSize
=
TTTOOLINFOA_V2_SIZE
-
1
;
ti
.
hwnd
=
NULL
;
ti
.
hinst
=
GetModuleHandleA
(
NULL
);
ti
.
uFlags
=
0
;
ti
.
uId
=
0x1234ABCD
;
ti
.
lpszText
=
NULL
;
ti
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
ti
.
rect
);
r
=
SendMessage
(
hwnd
,
TTM_ADDTOOLA
,
0
,
(
LPARAM
)
&
ti
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
ti
.
cbSize
=
TTTOOLINFOA_V2_SIZE
-
1
;
ti
.
hwnd
=
NULL
;
ti
.
uId
=
0x1234ABCD
;
SendMessage
(
hwnd
,
TTM_DELTOOLA
,
0
,
(
LPARAM
)
&
ti
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
ti
.
cbSize
=
TTTOOLINFOA_V2_SIZE
+
1
;
ti
.
hwnd
=
NULL
;
ti
.
hinst
=
GetModuleHandleA
(
NULL
);
ti
.
uFlags
=
0
;
ti
.
uId
=
0x1234ABCD
;
ti
.
lpszText
=
NULL
;
ti
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
ti
.
rect
);
r
=
SendMessage
(
hwnd
,
TTM_ADDTOOLA
,
0
,
(
LPARAM
)
&
ti
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
ti
.
cbSize
=
TTTOOLINFOA_V2_SIZE
+
1
;
ti
.
hwnd
=
NULL
;
ti
.
uId
=
0x1234ABCD
;
SendMessage
(
hwnd
,
TTM_DELTOOLA
,
0
,
(
LPARAM
)
&
ti
);
r
=
SendMessage
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
DestroyWindow
(
hwnd
);
/* 2. test size parameter validation rules (w-messages) */
hwnd
=
CreateWindowExW
(
0
,
TOOLTIPS_CLASSW
,
NULL
,
0
,
10
,
10
,
300
,
100
,
NULL
,
NULL
,
NULL
,
0
);
if
(
!
hwnd
)
{
win_skip
(
"CreateWindowExW() not supported. Skipping.
\n
"
);
return
;
}
tiW
.
cbSize
=
TTTOOLINFOW_V1_SIZE
-
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
hinst
=
GetModuleHandleA
(
NULL
);
tiW
.
uFlags
=
0
;
tiW
.
uId
=
0x1234ABCD
;
tiW
.
lpszText
=
NULL
;
tiW
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
tiW
.
rect
);
r
=
SendMessageW
(
hwnd
,
TTM_ADDTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
tiW
.
cbSize
=
TTTOOLINFOW_V1_SIZE
-
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
uId
=
0x1234ABCD
;
SendMessageW
(
hwnd
,
TTM_DELTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
tiW
.
cbSize
=
TTTOOLINFOW_V2_SIZE
-
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
hinst
=
GetModuleHandleA
(
NULL
);
tiW
.
uFlags
=
0
;
tiW
.
uId
=
0x1234ABCD
;
tiW
.
lpszText
=
NULL
;
tiW
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
tiW
.
rect
);
r
=
SendMessageW
(
hwnd
,
TTM_ADDTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
tiW
.
cbSize
=
TTTOOLINFOW_V2_SIZE
-
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
uId
=
0x1234ABCD
;
SendMessageW
(
hwnd
,
TTM_DELTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
tiW
.
cbSize
=
TTTOOLINFOW_V2_SIZE
+
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
hinst
=
GetModuleHandleA
(
NULL
);
tiW
.
uFlags
=
0
;
tiW
.
uId
=
0x1234ABCD
;
tiW
.
lpszText
=
NULL
;
tiW
.
lParam
=
0xdeadbeef
;
GetClientRect
(
hwnd
,
&
tiW
.
rect
);
r
=
SendMessageW
(
hwnd
,
TTM_ADDTOOLA
,
0
,
(
LPARAM
)
&
tiW
);
ok
(
r
,
"Adding the tool to the tooltip failed
\n
"
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
/* looks like TTM_DELTOOLW doesn't work with invalid size */
tiW
.
cbSize
=
TTTOOLINFOW_V2_SIZE
+
1
;
tiW
.
hwnd
=
NULL
;
tiW
.
uId
=
0x1234ABCD
;
SendMessageW
(
hwnd
,
TTM_DELTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
1
,
r
);
tiW
.
cbSize
=
TTTOOLINFOW_V2_SIZE
;
tiW
.
hwnd
=
NULL
;
tiW
.
uId
=
0x1234ABCD
;
SendMessageW
(
hwnd
,
TTM_DELTOOLW
,
0
,
(
LPARAM
)
&
tiW
);
r
=
SendMessageW
(
hwnd
,
TTM_GETTOOLCOUNT
,
0
,
0
);
expect
(
0
,
r
);
DestroyWindow
(
hwnd
);
}
START_TEST
(
tooltips
)
...
...
dlls/comctl32/tooltips.c
View file @
f394bed5
...
...
@@ -1027,8 +1027,6 @@ TOOLTIPS_AddToolA (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOA *lpToolInfo)
if
(
lpToolInfo
==
NULL
)
return
FALSE
;
if
(
lpToolInfo
->
cbSize
<
TTTOOLINFOA_V1_SIZE
)
return
FALSE
;
TRACE
(
"add tool (%p) %p %ld%s!
\n
"
,
infoPtr
->
hwndSelf
,
lpToolInfo
->
hwnd
,
lpToolInfo
->
uId
,
...
...
@@ -1116,8 +1114,6 @@ TOOLTIPS_AddToolW (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolInfo)
if
(
lpToolInfo
==
NULL
)
return
FALSE
;
if
(
lpToolInfo
->
cbSize
<
TTTOOLINFOW_V1_SIZE
)
return
FALSE
;
TRACE
(
"add tool (%p) %p %ld%s!
\n
"
,
infoPtr
->
hwndSelf
,
lpToolInfo
->
hwnd
,
lpToolInfo
->
uId
,
...
...
@@ -1279,8 +1275,6 @@ TOOLTIPS_DelToolA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo)
if
(
lpToolInfo
==
NULL
)
return
0
;
if
(
lpToolInfo
->
cbSize
<
TTTOOLINFOA_V1_SIZE
)
return
0
;
if
(
infoPtr
->
uNumTools
==
0
)
return
0
;
...
...
@@ -1299,7 +1293,8 @@ TOOLTIPS_DelToolW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo)
if
(
lpToolInfo
==
NULL
)
return
0
;
if
(
lpToolInfo
->
cbSize
<
TTTOOLINFOW_V1_SIZE
)
if
(
lpToolInfo
->
cbSize
>
TTTOOLINFOW_V2_SIZE
&&
lpToolInfo
->
cbSize
!=
TTTOOLINFOW_V3_SIZE
)
return
0
;
if
(
infoPtr
->
uNumTools
==
0
)
return
0
;
...
...
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