Menu crash - was : Re: [PATCH] Version info for comctl32.dll

gerard patel gerard.patel at asi.fr
Sat Mar 17 08:04:42 CST 2001


At 10:26 PM 16/03/2001 -0500, you wrote:
>
>On a related note, I provoked that crash in menu.c again, this time by
>hitting an accelerator key (?) for a button that was not enabled at the
>time. 

First thanks for the bug report.

The trace is not difficult to read, the menu item is a text item and
the text pointer is NULL.  MENU_CalcItemSize is not handling this
case. What is strange is this problem appears only with my patch. Maybe
your app is really initializing the menu when receiving the WM_INITMENU
message, but *only* when there is need to display the menu. I  can't see
how it could find out about it, though.

Anyway, could you try the following patch ? It tries to remove the main
case I saw where the app can set a menu item to  text type with a null text
pointer. It is a legitimate patch by itself, even if it does not fix your problem.
Maybe it could have nasty side effects. If it avoids the systematic crash,
try to find if the other is really gone for good too.

I have found a strangeness in the HEAP_strdup macros - WARNING -
this is of interest to anyone dabbling with Wine code.
While HEAP_strdupW and HEAP_strdupAtoW appear very similar, the specs
are not the same; one returns a  null pointer when called with a
null pointer, the other allocates 2 bytes of memory and returns a pointer
to it. Nice trap :-)

Gerard

--- menu.c.orig Wed Mar 14 20:19:46 2001
+++ menu.c      Sat Mar 17 14:47:30 2001
@@ -4524,11 +4524,15 @@
 
        menu->text = lpmii->dwTypeData;
 
-       if (IS_STRING_ITEM(menu->fType) && menu->text) {
-           if (unicode)
-               menu->text = HEAP_strdupW(GetProcessHeap(), 0,  lpmii->dwTypeData);
-           else
-               menu->text = HEAP_strdupAtoW(GetProcessHeap(), 0, (LPSTR)lpmii->dwTypeData);
+       if (IS_STRING_ITEM(menu->fType)) {
+            if (menu->text) {
+                if (unicode)
+                   menu->text = HEAP_strdupW(GetProcessHeap(), 0,  lpmii->dwTypeData);
+                else
+                   menu->text = HEAP_strdupAtoW(GetProcessHeap(), 0, (LPSTR)lpmii->dwTypeData);
+                }
+            else
+                menu->fType |= MF_SEPARATOR;
        }
     }
                 





More information about the wine-devel mailing list