Fixed crash when accessing sysmenu.

This commit is contained in:
Eric Pouech 1999-08-21 12:59:44 +00:00 committed by Alexandre Julliard
parent 99b15133b9
commit 562309adac
1 changed files with 18 additions and 9 deletions

View File

@ -3783,6 +3783,7 @@ HMENU16 WINAPI GetSystemMenu16( HWND16 hWnd, BOOL16 bRevert )
HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert ) HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
{ {
WND *wndPtr = WIN_FindWndPtr( hWnd ); WND *wndPtr = WIN_FindWndPtr( hWnd );
HMENU retvalue = 0;
if (wndPtr) if (wndPtr)
{ {
@ -3797,8 +3798,17 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
{ {
POPUPMENU *menu = (POPUPMENU*) POPUPMENU *menu = (POPUPMENU*)
USER_HEAP_LIN_ADDR(wndPtr->hSysMenu); USER_HEAP_LIN_ADDR(wndPtr->hSysMenu);
if( menu->nItems > 0 && menu->items[0].hSubMenu == MENU_DefSysPopup ) if( IS_A_MENU(menu) )
menu->items[0].hSubMenu = MENU_CopySysPopup(); {
if( menu->nItems > 0 && menu->items[0].hSubMenu == MENU_DefSysPopup )
menu->items[0].hSubMenu = MENU_CopySysPopup();
}
else
{
WARN("Current sys-menu (%04x) of wnd %04x is broken\n",
wndPtr->hSysMenu, hWnd);
wndPtr->hSysMenu = 0;
}
} }
} }
@ -3807,19 +3817,18 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
if( wndPtr->hSysMenu ) if( wndPtr->hSysMenu )
{ {
HMENU retvalue = GetSubMenu16(wndPtr->hSysMenu, 0); POPUPMENU *menu;
retvalue = GetSubMenu16(wndPtr->hSysMenu, 0);
/* Store the dummy sysmenu handle to facilitate the refresh */ /* Store the dummy sysmenu handle to facilitate the refresh */
/* of the close button if the SC_CLOSE item change */ /* of the close button if the SC_CLOSE item change */
POPUPMENU *menu = (POPUPMENU*) USER_HEAP_LIN_ADDR(retvalue); menu = (POPUPMENU*) USER_HEAP_LIN_ADDR(retvalue);
menu->hSysMenuOwner = wndPtr->hSysMenu; if ( IS_A_MENU(menu) )
menu->hSysMenuOwner = wndPtr->hSysMenu;
WIN_ReleaseWndPtr(wndPtr);
return retvalue;
} }
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);
} }
return 0; return retvalue;
} }