Cleanup & fix potential NULL pointer dereferencing.

This commit is contained in:
Bastien Montagne 2017-08-10 10:27:47 +02:00
parent a152743ba3
commit cf7a2c93e3
1 changed files with 9 additions and 11 deletions

View File

@ -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;
}