[2/2] user32: DialogBoxParam should return -1 when dialog control creation fails.

Dmitry Timoshkov dmitry at baikal.ru
Fri Aug 18 06:42:11 CDT 2017


This patch fixes bugs #40025 and #40609.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/user32/dialog.c       | 8 ++++++--
 dlls/user32/tests/dialog.c | 1 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 8b77ae2158..ee06ba82a4 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -835,11 +835,13 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
     HRSRC hrsrc;
     LPCDLGTEMPLATEA ptr;
 
+    if (owner && !IsWindow(owner)) return 0;
+
     if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return -1;
     if (!(ptr = LoadResource(hInst, hrsrc))) return -1;
     hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, &owner );
     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
-    return 0;
+    return -1;
 }
 
 
@@ -853,11 +855,13 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
     HRSRC hrsrc;
     LPCDLGTEMPLATEW ptr;
 
+    if (owner && !IsWindow(owner)) return 0;
+
     if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1;
     if (!(ptr = LoadResource(hInst, hrsrc))) return -1;
     hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, &owner );
     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
-    return 0;
+    return -1;
 }
 
 
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index ac61d4e56c..8bf76f112c 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -1273,7 +1273,6 @@ static void test_DialogBoxParamA(void)
 
     SetLastError(0xdeadbeef);
     ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_DIALOG_INVALID_CLASS", 0, DestroyDlgWinProc, 0);
-todo_wine
     ok(ret == -1, "DialogBoxParamA returned %ld, expected -1\n", ret);
     ok(GetLastError() == 0, "got %d\n", GetLastError());
 
-- 
2.14.1




More information about the wine-patches mailing list