Fix possible crash with custom (add-on defined) icons

This change is a simple null check on the ID provided to icon_set_image() which
appears to be a legitimate value for the ID when used by some addins
(discovered with PowerSave shortly after syncing to main).

Differential Revision: https://developer.blender.org/D9866

Reviewed by: Julian Eisel
This commit is contained in:
Eric Cosky 2020-12-16 12:12:06 +01:00 committed by Julian Eisel
parent 3fc9fc1cb4
commit 4f128269b2
Notes: blender-bot 2023-02-14 05:25:44 +01:00
Referenced by issue #83829, Crash when opening the Add > Mesh menu or pressing SHIFT+A
1 changed files with 1 additions and 1 deletions

View File

@ -1416,7 +1416,7 @@ static void icon_set_image(const bContext *C,
const bool delay = prv_img->rect[size] != NULL;
icon_create_rect(prv_img, size);
if (use_job && BKE_previewimg_id_supports_jobs(id)) {
if (use_job && (!id || BKE_previewimg_id_supports_jobs(id))) {
/* Job (background) version */
ED_preview_icon_job(
C, prv_img, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size], delay);