From 4925186bb2fd4e0d3a985c3e9b027189f9564f93 Mon Sep 17 00:00:00 2001 From: Juergen Schmied Date: Thu, 13 May 1999 18:42:03 +0000 Subject: [PATCH] - prevent crash when GetMenuDefaultItem is called on empty menu - set default item on system menu --- controls/menu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controls/menu.c b/controls/menu.c index c2534faea0c..90359128481 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -279,6 +279,7 @@ static HMENU MENU_CopySysPopup(void) if( hMenu ) { POPUPMENU* menu = (POPUPMENU *) USER_HEAP_LIN_ADDR(hMenu); menu->wFlags |= MF_SYSMENU | MF_POPUP; + SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE); } else { hMenu = 0; @@ -4395,6 +4396,10 @@ UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags) /* find default item */ item = menu->items; + + /* empty menu */ + if (! item) return -1; + while ( !( item->fState & MFS_DEFAULT ) ) { i++; item++; -- 2.11.4.GIT