diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-11 16:35:03 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-11 16:37:38 +0300 |
commit | 4bee1e1c8c390388b30fcadee3c4127b5b9e7f8c (patch) | |
tree | 4cd0f7137c732a097314906fa2ac7709372015b3 /source | |
parent | 836b99ce4926eea91655eb7642aea40d29b286df (diff) |
Fix broken logic in lib_query that could lead to NULL id_owner pointer.
Issue revealed by own recent cleanup in rB8820ab4, and moticed by
@brecht, thanks.
Note that am not 100% sure whether we should allow call on lib_query
without a proper valid owner_id, for embedded data-blocks. But this can
be investifated later, so far things have been working like that.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 2a66624f88f..b022cc1720b 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -587,7 +587,12 @@ static void library_foreach_ID_link(Main *bmain, for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) { data.self_id = id; - data.owner_id = (id->flag & LIB_EMBEDDED_DATA) ? id_owner : data.self_id; + /* Note that we may call this functions sometime directly on an embedded ID, without any + * knowledge of the owner ID then. + * While not great, and that should be probably sanitized at some point, we cal live with it + * for now. */ + data.owner_id = ((id->flag & LIB_EMBEDDED_DATA) != 0 && id_owner != NULL) ? id_owner : + data.self_id; /* inherit_data is non-NULL when this function is called for some sub-data ID * (like root nodetree of a material). |