From 126d59efdd4b2533fde04bdeeaad2fb77f0db64e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 13 Dec 2024 11:28:27 +0100 Subject: [PATCH] Fix: UI: Crash when trying to display invalid icon Requesting an icon from an invalid icon ID was always handled gracefully, resulting in the icon not being shown and an error print in debug mode. 2b7a968909 caused a null pointer dereference in that case, leading to a crash. --- source/blender/editors/interface/interface_icons.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 92482a08554..9005f3240b9 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -1469,11 +1469,6 @@ static void icon_draw_size(float x, Icon *icon = BKE_icon_get(icon_id); - if (icon->obj_type != ICON_DATA_STUDIOLIGHT) { - /* Icon alpha should not apply to MatCap/Studio lighting. #80356. */ - alpha *= btheme->tui.icon_alpha; - } - if (icon == nullptr) { if (G.debug & G_DEBUG) { printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); @@ -1481,6 +1476,11 @@ static void icon_draw_size(float x, return; } + if (icon->obj_type != ICON_DATA_STUDIOLIGHT) { + /* Icon alpha should not apply to MatCap/Studio lighting. #80356. */ + alpha *= btheme->tui.icon_alpha; + } + /* scale width and height according to aspect */ int w = int(fdraw_size / aspect + 0.5f); int h = int(fdraw_size / aspect + 0.5f);