]> granicus.if.org Git - nethack/commitdiff
Fix crash that occurs when closing application window while invetory is displayed.
authorBart House <bart@barthouse.com>
Sat, 2 Sep 2017 21:12:32 +0000 (14:12 -0700)
committerPasi Kallinen <paxed@alt.org>
Mon, 4 Sep 2017 09:52:18 +0000 (12:52 +0300)
win/win32/mhmenu.c

index 6c07b5081336e333964b7f6390e9577cc6dbc681..28a37a25698f5ac677454e929910ffb06099eba5 100644 (file)
@@ -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 {