Unicode/Ansi message translation fix for NULL string pointers.

Rein Klazes rklazes at casema.net
Tue Mar 13 11:21:37 CST 2001


Hi,

Some messages, eg LB_ADDSTRING with a valid zero value for lparam
(ownerdrawn listbox), are silently dropped during the unicode/Ansi
tranlation. Same thing happens in case of the LB_FINDSTRING and
similar messages where  NULL pointers to strings are allowed ( and
treated in Windows as empty strings). Attached patch, corrects this by
leaving the NULL unchanged.
In addition I propose to output an ERROR when the translation fails
for one reason or another. 

This fixes the global search function in Agent 32.

Changelog:

	windows:	winproc.c
	Fix Unicode/Ansi message translation for some listbox/combobox
	messages with a zero valued lparam. Output an error when the
	translation fails.


Rein.
-- 
Rein Klazes
rklazes at casema.net
-------------- next part --------------
--- ./wine/windows/winproc.c	Mon Feb 12 07:51:03 2001
+++ ./mywine/windows/winproc.c	Tue Mar 13 17:42:05 2001
@@ -577,6 +577,7 @@
     case LB_FINDSTRINGEXACT:
     case LB_SELECTSTRING:
     case EM_REPLACESEL:
+        if(!*plparam) return 0;
         *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
         return (*plparam ? 1 : -1);
 
@@ -620,6 +621,7 @@
 /* Listbox */
     case LB_ADDSTRING:
     case LB_INSERTSTRING:
+        if(!*plparam) return 0;
 	if ( WINPROC_TestLBForStr( hwnd ))
           *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
         return (*plparam ? 1 : -1);
@@ -637,6 +639,7 @@
 /* Combobox */
     case CB_ADDSTRING:
     case CB_INSERTSTRING:
+        if(!*plparam) return 0;
 	if ( WINPROC_TestCBForStr( hwnd ))
           *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
         return (*plparam ? 1 : -1);
@@ -825,6 +828,7 @@
     case LB_FINDSTRINGEXACT:
     case LB_SELECTSTRING:
     case EM_REPLACESEL:
+        if(!*plparam) return 0;
         *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
         return (*plparam ? 1 : -1);
 
@@ -863,6 +867,7 @@
 /* Listbox */
     case LB_ADDSTRING:
     case LB_INSERTSTRING:
+        if(!*plparam) return 0;
 	if ( WINPROC_TestLBForStr( hwnd ))
           *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
         return (*plparam ? 1 : -1);
@@ -880,6 +885,7 @@
 /* Combobox */
     case CB_ADDSTRING:
     case CB_INSERTSTRING:
+        if(!*plparam) return 0;
 	if ( WINPROC_TestCBForStr( hwnd ))
           *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
         return (*plparam ? 1 : -1);
@@ -2354,10 +2360,15 @@
                                          LPARAM lParam )
 {
     LRESULT result;
+    int unmap;
 
-    if (WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam ) == -1) return 0;
+    if( (unmap = WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam )) == -1) {
+        ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
+                       SPY_GetMsgName(msg), wParam, lParam );
+        return 0;
+    }
     result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
-    WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
+    if( unmap ) WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
     return result;
 }
 
@@ -2372,10 +2383,15 @@
                                          LPARAM lParam )
 {
     LRESULT result;
+    int unmap;
 
-    if (WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam ) == -1) return 0;
+    if ((unmap = WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam )) == -1) {
+        ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
+                       SPY_GetMsgName(msg), wParam, lParam );
+        return 0;
+    }
     result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
-    WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
+    if( unmap ) WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
     return result;
 }
 


More information about the wine-patches mailing list