Cleanup & fix potential NULL pointer dereferencing.
This commit is contained in:
parent
a152743ba3
commit
cf7a2c93e3
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue