From be4e0992e66ef081e51d2b1d96a49003450302b0 Mon Sep 17 00:00:00 2001 From: Bart House Date: Sat, 2 Sep 2017 14:12:32 -0700 Subject: [PATCH] Fix crash that occurs when closing application window while invetory is displayed. --- win/win32/mhmenu.c | 5 +++++ 1 file changed, 5 insertions(+) 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 { -- 2.40.0