[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40810] trunk/blender/source/blender/ editors/sculpt_paint/paint_vertex.c: fix for memory leak when calling wpaint_make_validmap() with no vertex groups.

Campbell Barton ideasman42 at gmail.com
Thu Oct 6 03:51:04 CEST 2011


Revision: 40810
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40810
Author:   campbellbarton
Date:     2011-10-06 01:51:01 +0000 (Thu, 06 Oct 2011)
Log Message:
-----------
fix for memory leak when calling wpaint_make_validmap() with no vertex groups.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2011-10-06 01:29:32 UTC (rev 40809)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2011-10-06 01:51:01 UTC (rev 40810)
@@ -1812,17 +1812,20 @@
 	bDeformGroup *dg;
 	ModifierData *md;
 	char *vgroup_validmap;
-	GHash *gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wpaint_make_validmap gh");
+	GHash *gh;
 	int i = 0, step1=1;
 
+	if(ob->defbase.first == NULL) {
+		return NULL;
+	}
+
+	gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wpaint_make_validmap gh");
+
 	/*add all names to a hash table*/
-	for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) {
+	for (dg=ob->defbase.first; dg; dg=dg->next) {
 		BLI_ghash_insert(gh, dg->name, NULL);
 	}
 
-	if (!i)
-		return NULL;
-
 	vgroup_validmap= MEM_callocN(i, "wpaint valid map");
 
 	/*now loop through the armature modifiers and identify deform bones*/




More information about the Bf-blender-cvs mailing list