Corrected: Zero out return string in GetMenuStr

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Wed Mar 30 02:27:07 CST 2005


Changelog:
	dlls/user/menu.c: GetMenuStrA|W
	Initialize return string as an empty string

Xilinx ISE7.1 _pn.exe checked the return string length even for separators
and got astray.

-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/user/menu.c
===================================================================
RCS file: /home/wine/wine/dlls/user/menu.c,v
retrieving revision 1.22
diff -u -w -r1.22 menu.c
--- wine/dlls/user/menu.c	25 Mar 2005 20:47:32 -0000	1.22
+++ wine/dlls/user/menu.c	30 Mar 2005 08:24:25 -0000
@@ -3277,10 +3277,11 @@
     MENUITEM *item;
 
     TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
+    if (str && nMaxSiz)
+        str[0] = '\0';
     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
     if (!IS_STRING_ITEM(item->fType)) return 0;
     if (!str || !nMaxSiz) return strlenW(item->text);
-    str[0] = '\0';
     if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL ))
         str[nMaxSiz-1] = 0;
     TRACE("returning '%s'\n", str );
@@ -3296,11 +3297,12 @@
 {
     MENUITEM *item;
 
+    if (str && nMaxSiz)
+        str[0] = '\0';
     TRACE("menu=%p item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags );
     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
     if (!IS_STRING_ITEM(item->fType)) return 0;
     if (!str || !nMaxSiz) return strlenW(item->text);
-    str[0] = '\0';
     lstrcpynW( str, item->text, nMaxSiz );
     return strlenW(str);
 }



More information about the wine-patches mailing list