riched20: hWnd validity test in window procedure
Krzysztof Foltman
wdev at foltman.com
Fri Jun 23 15:19:31 CDT 2006
ChangeLog:
* Added hWnd validity check to work around buggy apps (bug# 4452)
This patch is based on Phil Krylov's one, with two differences: it
checks the handle even before trying to call GetWindowLong, and it
checks for invalid window handle, not just NULL.
Krzysztof
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 9a2b966..50527ca 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1393,8 +1394,16 @@ get_msg_name(UINT msg)
*/
LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SCROLLINFO si;
- ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongW(hWnd, 0);
-
+ ME_TextEditor *editor;
+
+ /* Some braindead subclassed window procedures call the original procedure
+ * with NULL or invalid window handle */
+ if (!hWnd || !IsWindow(hWnd)) {
+ ERR("RichEditANSIWndProc called with invalid hWnd %p - application bug?\n", hWnd);
+ return 0;
+ }
+
+ editor = (ME_TextEditor *)GetWindowLongW(hWnd, 0);
TRACE("hWnd %p msg %04x (%s) %08x %08lx\n",
hWnd, msg, get_msg_name(msg), wParam, lParam);
More information about the wine-patches
mailing list