testtext might be passed to DefWindowProcW in test_aw_conversion_dlgprocA, so it must have a WCHAR null at the end.
* * *
@nsivov it's also potentially possible for a WCHAR string to go throught W->A conversion then be passed to DefWindowProcW. in that case i am not sure how to guarantee it is wide-null terminated. this doesn't current happen in our test cases though.
From: Yuxuan Shui yshui@codeweavers.com
testtext might be passed to DefWindowProcW in test_aw_conversion_dlgprocA, so it must have a WCHAR null at the end. --- dlls/user32/tests/dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index 7ea0d13c0f3..d77af346c68 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -1456,7 +1456,7 @@ static INT_PTR CALLBACK TestControlStyleDlgProc(HWND hdlg, UINT msg, }
static const WCHAR testtextW[] = {'W','n','d','T','e','x','t',0}; -static const char *testtext = "WndText"; +static const char *testtext = "WndText\0\0";
enum defdlgproc_text {
Nikolay Sivov (@nsivov) commented about dlls/user32/tests/dialog.c:
}
static const WCHAR testtextW[] = {'W','n','d','T','e','x','t',0}; -static const char *testtext = "WndText"; +static const char *testtext = "WndText\0\0";
I can only look at this as a way to silence the failure. Could you explain where it fails in code exactly?
On Tue Jun 17 16:51:10 2025 +0000, Nikolay Sivov wrote:
I can only look at this as a way to silence the failure. Could you explain where it fails in code exactly?
In `test_aw_conversion_dlgproc` we set DLGPROC to `test_aw_conversion_dlgprocA`, then we set "test_mode" to `DLGPROCTEXT_DLGPROCA`, and call `DefDlgProcA(hdlg, WM_SETTEXT, 0, (LPARAM)testtext)`.
So `testtext` gets passed as-is to `test_aw_conversion_dlgprocA`, which then passes it directly to `DefWindowProcW`. Since `DefWindowProcW` wants a wide string, it goes out-of-bound trying to `lstrlenW` it.
On Tue Jun 17 17:26:41 2025 +0000, Yuxuan Shui wrote:
In `test_aw_conversion_dlgproc` we set DLGPROC to `test_aw_conversion_dlgprocA`, then we set "test_mode" to `DLGPROCTEXT_DLGPROCA`, and call `DefDlgProcA(hdlg, WM_SETTEXT, 0, (LPARAM)testtext)`. So `testtext` gets passed as-is to `test_aw_conversion_dlgprocA`, which then passes it directly to `DefWindowProcW`. Since `DefWindowProcW` wants a wide string, it goes out-of-bound trying to `lstrlenW` it.
I see, in this case it's enough to use "WndText\0". Also please add a code comment why this constant has to be that way, simply stating that it's passed to the ProcW function.