[Bf-blender-cvs] [ef2151d73de] master: Fix T83776: Crashes with add-on's icon preview in menus
Julian Eisel
noreply at git.blender.org
Tue Dec 15 12:05:15 CET 2020
Commit: ef2151d73de87b3e7be631b6712283a727f8d4a6
Author: Julian Eisel
Date: Tue Dec 15 12:02:22 2020 +0100
Branches: master
https://developer.blender.org/rBef2151d73de87b3e7be631b6712283a727f8d4a6
Fix T83776: Crashes with add-on's icon preview in menus
Apparently the ID pointer can be NULL, which most code here assumes is
not the case. But it's very fragile & finicky, there is one code path
were it's allowed to be NULL.
Add necessary NULL-checks, an assert as sanity check and a comment to
note the possibility of NULL.
===================================================================
M source/blender/editors/render/render_preview.c
===================================================================
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 4466d9f434d..3c103f28d93 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -189,7 +189,7 @@ typedef struct IconPreview {
Main *bmain;
Scene *scene;
void *owner;
- ID *id, *id_copy;
+ ID *id, *id_copy; /* May be NULL! (see ICON_TYPE_PREVIEW case in #ui_icon_ensure_deferred()) */
ListBase sizes;
} IconPreview;
@@ -1235,6 +1235,8 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
ID *id = sp->id;
short idtype = GS(id->name);
+ BLI_assert(id != NULL);
+
if (idtype == ID_IM) {
Image *ima = (Image *)id;
ImBuf *ibuf = NULL;
@@ -1337,7 +1339,7 @@ static void other_id_types_preview_render(IconPreview *ip,
const bool is_render = !is_deferred;
/* These types don't use the ShaderPreview mess, they have their own types and functions. */
- BLI_assert(!ELEM(GS(ip->id->name), ID_OB));
+ BLI_assert(!ip->id || !ELEM(GS(ip->id->name), ID_OB));
/* construct shader preview from image size and previewcustomdata */
sp->scene = ip->scene;
@@ -1396,7 +1398,7 @@ static void icon_preview_startjob_all_sizes(void *customdata,
continue;
}
- if (ELEM(GS(ip->id->name), ID_OB)) {
+ if (ip->id && ELEM(GS(ip->id->name), ID_OB)) {
/* Much simpler than the ShaderPreview mess used for other ID types. */
object_preview_render(ip, cur_size);
}
More information about the Bf-blender-cvs
mailing list