[1/2] user32: Insert menu item only after contents of the passed in menu item info have been verified

Dmitry Timoshkov dmitry at codeweavers.com
Sun Jun 17 07:45:55 CDT 2007


Hello,

Changelog:
    user32: Insert menu item only after contents of the passed in menu item
    info have been verified.

---
 dlls/user32/menu.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 692a70c..6706e16 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -4639,6 +4639,9 @@ BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
                                  const MENUITEMINFOA *lpmii)
 {
     MENUITEMINFOA mii;
+
+    TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
+
     if( lpmii->cbSize != sizeof( mii) &&
             lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
         SetLastError( ERROR_INVALID_PARAMETER);
@@ -4660,6 +4663,9 @@ BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
                                  const MENUITEMINFOW *lpmii)
 {
     MENUITEMINFOW mii;
+
+    TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
+
     if( lpmii->cbSize != sizeof( mii) &&
             lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
         SetLastError( ERROR_INVALID_PARAMETER);
@@ -4771,8 +4777,11 @@ UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
 BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
                                 const MENUITEMINFOA *lpmii)
 {
-    MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
+    MENUITEM *item;
     MENUITEMINFOA mii;
+
+    TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, bypos, lpmii);
+
     if( lpmii->cbSize != sizeof( mii) &&
             lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
         SetLastError( ERROR_INVALID_PARAMETER);
@@ -4783,6 +4792,8 @@ BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
         mii.cbSize = sizeof( mii);
         mii.hbmpItem = NULL;
     }
+
+    item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
     return SetMenuItemInfo_common(item, (const MENUITEMINFOW *)&mii, FALSE);
 }
 
@@ -4793,8 +4804,11 @@ BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
 BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
                                 const MENUITEMINFOW *lpmii)
 {
-    MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
+    MENUITEM *item;
     MENUITEMINFOW mii;
+
+    TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, bypos, lpmii);
+
     if( lpmii->cbSize != sizeof( mii) &&
             lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
         SetLastError( ERROR_INVALID_PARAMETER);
@@ -4805,6 +4819,8 @@ BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
         mii.cbSize = sizeof( mii);
         mii.hbmpItem = NULL;
     }
+
+    item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
     return SetMenuItemInfo_common(item, &mii, TRUE);
 }
 
-- 
1.5.1.6






More information about the wine-patches mailing list