From: Bart House Date: Sat, 2 Sep 2017 21:12:32 +0000 (-0700) Subject: Fix crash that occurs when closing application window while invetory is displayed. X-Git-Tag: NetHack-3.6.1_RC01~400 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be4e0992e66ef081e51d2b1d96a49003450302b0;p=nethack Fix crash that occurs when closing application window while invetory is displayed. --- diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index 6c07b5081..28a37a256 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -884,6 +884,11 @@ GetMenuControl(HWND hWnd) data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); + /* We may continue getting window messages after a window's WM_DESTROY is + called. We need to handle the case that USERDATA has been freed. */ + if (data == NULL) + return NULL; + if (data->type == MENU_TYPE_TEXT) { return GetDlgItem(hWnd, IDC_MENU_TEXT); } else {