Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
99f0dc4f
Commit
99f0dc4f
authored
Dec 06, 2007
by
Alex Villacís Lasso
Committed by
Alexandre Julliard
Dec 07, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: WM_GETTEXT should return 0 on overflow but fill buffer anyway.
parent
4545f194
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
2 deletions
+57
-2
editor.c
dlls/riched20/editor.c
+23
-2
editor.c
dlls/riched20/tests/editor.c
+34
-0
No files found.
dlls/riched20/editor.c
View file @
99f0dc4f
...
...
@@ -2002,13 +2002,34 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
case
WM_GETTEXT
:
{
GETTEXTEX
ex
;
LRESULT
rc
;
LPSTR
bufferA
=
NULL
;
LPWSTR
bufferW
=
NULL
;
ex
.
cb
=
wParam
;
if
(
unicode
)
bufferW
=
richedit_alloc
((
wParam
+
2
)
*
sizeof
(
WCHAR
));
else
bufferA
=
richedit_alloc
(
wParam
+
2
);
ex
.
cb
=
wParam
+
(
unicode
?
2
*
sizeof
(
WCHAR
)
:
2
);
ex
.
flags
=
GT_USECRLF
;
ex
.
codepage
=
unicode
?
1200
:
CP_ACP
;
ex
.
lpDefaultChar
=
NULL
;
ex
.
lpUsedDefaultChar
=
NULL
;
return
RichEditWndProc_common
(
hWnd
,
EM_GETTEXTEX
,
(
WPARAM
)
&
ex
,
lParam
,
unicode
);
rc
=
RichEditWndProc_common
(
hWnd
,
EM_GETTEXTEX
,
(
WPARAM
)
&
ex
,
unicode
?
(
LPARAM
)
bufferW
:
(
LPARAM
)
bufferA
,
unicode
);
if
(
unicode
)
{
memcpy
((
LPWSTR
)
lParam
,
bufferW
,
wParam
);
if
(
lstrlenW
(
bufferW
)
>=
wParam
/
sizeof
(
WCHAR
))
rc
=
0
;
}
else
{
memcpy
((
LPSTR
)
lParam
,
bufferA
,
wParam
);
if
(
strlen
(
bufferA
)
>=
wParam
)
rc
=
0
;
}
if
(
bufferA
!=
NULL
)
richedit_free
(
bufferA
);
if
(
bufferW
!=
NULL
)
richedit_free
(
bufferW
);
return
rc
;
}
case
EM_GETTEXTEX
:
{
...
...
dlls/riched20/tests/editor.c
View file @
99f0dc4f
...
...
@@ -656,14 +656,48 @@ static void test_WM_GETTEXT(void)
{
HWND
hwndRichEdit
=
new_richedit
(
NULL
);
static
const
char
text
[]
=
"Hello. My name is RichEdit!"
;
static
const
char
text2
[]
=
"Hello. My name is RichEdit!
\r
"
;
static
const
char
text2_after
[]
=
"Hello. My name is RichEdit!
\r\n
"
;
char
buffer
[
1024
]
=
{
0
};
int
result
;
/* Baseline test with normal-sized buffer */
SendMessage
(
hwndRichEdit
,
WM_SETTEXT
,
0
,
(
LPARAM
)
text
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
strlen
(
buffer
),
"WM_GETTEXT returned %d, expected %d
\n
"
,
result
,
strlen
(
buffer
));
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
strcmp
(
buffer
,
text
);
ok
(
result
==
0
,
"WM_GETTEXT: settext and gettext differ. strcmp: %d
\n
"
,
result
);
/* Test for behavior in overflow case */
memset
(
buffer
,
0
,
1024
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
strlen
(
text
),
(
LPARAM
)
buffer
);
ok
(
result
==
0
,
"WM_GETTEXT returned %d, expected 0
\n
"
,
result
);
result
=
strcmp
(
buffer
,
text
);
ok
(
result
==
0
,
"WM_GETTEXT: settext and gettext differ. strcmp: %d
\n
"
,
result
);
/* Baseline test with normal-sized buffer and carriage return */
SendMessage
(
hwndRichEdit
,
WM_SETTEXT
,
0
,
(
LPARAM
)
text2
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
strlen
(
buffer
),
"WM_GETTEXT returned %d, expected %d
\n
"
,
result
,
strlen
(
buffer
));
result
=
strcmp
(
buffer
,
text2_after
);
ok
(
result
==
0
,
"WM_GETTEXT: settext and gettext differ. strcmp: %d
\n
"
,
result
);
/* Test for behavior of CRLF conversion in case of overflow */
memset
(
buffer
,
0
,
1024
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
strlen
(
text2
),
(
LPARAM
)
buffer
);
ok
(
result
==
0
,
"WM_GETTEXT returned %d, expected 0
\n
"
,
result
);
result
=
strcmp
(
buffer
,
text2
);
ok
(
result
==
0
,
"WM_GETTEXT: settext and gettext differ. strcmp: %d
\n
"
,
result
);
DestroyWindow
(
hwndRichEdit
);
}
...
...
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