[Bf-blender-cvs] [cf7a2c93e3a] master: Cleanup & fix potential NULL pointer dereferencing.

Bastien Montagne noreply at git.blender.org
Thu Aug 10 11:13:07 CEST 2017


Commit: cf7a2c93e3a897a3300bc7df527c8ba271da0424
Author: Bastien Montagne
Date:   Thu Aug 10 10:27:47 2017 +0200
Branches: master
https://developer.blender.org/rBcf7a2c93e3a897a3300bc7df527c8ba271da0424

Cleanup & fix potential NULL pointer dereferencing.

===================================================================

M	source/blender/blenkernel/intern/library.c

===================================================================

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




More information about the Bf-blender-cvs mailing list