[Bf-blender-cvs] [480ed9d] fracture_modifier: crash fix: automatic material names management was wrong (got internally longer and longer and caused a stack overflow after some fracture attempts)

Martin Felke noreply at git.blender.org
Sat Dec 27 16:21:46 CET 2014


Commit: 480ed9df622304eced36b9f149313c2335421544
Author: Martin Felke
Date:   Sat Dec 27 16:21:34 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rB480ed9df622304eced36b9f149313c2335421544

crash fix: automatic material names management was wrong (got internally longer and longer and caused a stack overflow after some fracture attempts)

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

M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index dec093f..9a59a2e 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -859,19 +859,17 @@ static Material* find_material(const char* name)
 
 	for (mat = G.main->mat.first; mat; mat = mat->next)
 	{
-		if (strlen(name) <= MAX_ID_NAME - 2)
+		char *cmp = BLI_strdupcat("MA", name);
+		if (strcmp(cmp, mat->name) == 0)
 		{
-			char *ptr;
-			char tmpnam[MAX_ID_NAME];
-			tmpnam[0] = 'M';
-			tmpnam[1] = 'A';
-
-			ptr = strcat(tmpnam, name);
-			//printf("%s %s %s\n", ptr, tmpnam, mat->name);
-			if (strcmp(ptr, mat->name) == 0)
-			{
-				return (Material*)mat;
-			}
+			MEM_freeN(cmp);
+			cmp = NULL;
+			return (Material*)mat;
+		}
+		else
+		{
+			MEM_freeN(cmp);
+			cmp = NULL;
 		}
 	}




More information about the Bf-blender-cvs mailing list