diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-10 11:27:47 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-10 11:28:13 +0300 |
commit | cf7a2c93e3a897a3300bc7df527c8ba271da0424 (patch) | |
tree | 1ee99e3e58e3692564f709f875eadf495a8649a0 /source/blender/blenkernel/intern/library.c | |
parent | a152743ba31d8307efe70b6024fa81212b597362 (diff) |
Cleanup & fix potential NULL pointer dereferencing.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0ccf67e7f8e..a1bd410d390 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1099,22 +1099,20 @@ void *BKE_libblock_alloc_notest(short type) */ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int flag) { - ID *id = NULL; - BLI_assert((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0); - - id = BKE_libblock_alloc_notest(type); - if ((flag & LIB_ID_CREATE_NO_MAIN) != 0) { - id->tag |= LIB_TAG_NO_MAIN; - } - if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0) { - id->tag |= LIB_TAG_NO_USER_REFCOUNT; - } + ID *id = BKE_libblock_alloc_notest(type); if (id) { + if ((flag & LIB_ID_CREATE_NO_MAIN) != 0) { + id->tag |= LIB_TAG_NO_MAIN; + } + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0) { + id->tag |= LIB_TAG_NO_USER_REFCOUNT; + } + id->icon_id = 0; - *( (short *)id->name) = type; + *((short *)id->name) = type; if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { id->us = 1; } |