Fix T61487: quick favorites crash outside of open preferences window
authorPhilipp Oeser <info@graphics-engineer.com>
Wed, 13 Feb 2019 10:02:47 +0000 (11:02 +0100)
committerPhilipp Oeser <info@graphics-engineer.com>
Wed, 13 Feb 2019 10:05:14 +0000 (11:05 +0100)
source/blender/editors/interface/interface_context_menu.c
source/blender/editors/screen/screen_user_menu.c

index 0f5d3bb..d8928e8 100644 (file)
@@ -710,7 +710,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
                                item_found = true;
                        }
                }
-               MEM_freeN(um_array);
+               if (um_array) {
+                       MEM_freeN(um_array);
+               }
 
                if (!item_found) {
                        but2 = uiDefIconTextBut(
index d0cc153..1f49eb2 100644 (file)
@@ -59,6 +59,11 @@ bUserMenu **ED_screen_user_menus_find(const bContext *C, uint *r_len)
        SpaceLink *sl = CTX_wm_space_data(C);
        const char *context = CTX_data_mode_string(C);
 
+       if (sl == NULL) {
+               *r_len = 0;
+               return NULL;
+       }
+
        uint array_len = 3;
        bUserMenu **um_array = MEM_calloc_arrayN(array_len, sizeof(*um_array), __func__);
        um_array[0] = BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context);
@@ -253,7 +258,9 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
                        }
                }
        }
-       MEM_freeN(um_array);
+       if (um_array) {
+               MEM_freeN(um_array);
+       }
 
        if (is_empty) {
                uiItemL(menu->layout, IFACE_("No menu items found"), ICON_NONE);