Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-12-15 14:02:22 +0300
committerJulian Eisel <julian@blender.org>2020-12-15 14:05:12 +0300
commitef2151d73de87b3e7be631b6712283a727f8d4a6 (patch)
treec76a93689d9d86d75b8f5929c16c878d520fbd82 /source
parent1b130f17c9b2b82177b02f64d7e9189ff175f28c (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/render/render_preview.c8
1 files changed, 5 insertions, 3 deletions
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);
}