- check if the requested MenuItem object was really found
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 8 May 2008 07:46:46 +0000 (07:46 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 8 May 2008 07:46:46 +0000 (07:46 +0000)
- makes user32_winetest not crash reactos

svn path=/trunk/; revision=33361

reactos/subsystems/win32/win32k/ntuser/menu.c

index 39005dd..c7f0f12 100644 (file)
@@ -930,7 +930,7 @@ IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
 {
    int pos = (int)uItem;
    PMENU_ITEM MenuItem;
-   PMENU_OBJECT SubMenu;
+   PMENU_OBJECT SubMenu = NULL;
 
    if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount)
    {
@@ -951,6 +951,13 @@ IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
    {
       pos = IntGetMenuItemByFlag(MenuObject, uItem, MF_BYCOMMAND, &SubMenu, NULL, NULL);
    }
+   if (SubMenu == NULL)
+   {
+       SetLastWin32Error(ERROR_INVALID_PARAMETER);
+       return FALSE;
+   }
+
+
    if (pos < -1)
    {
       pos = -1;