[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31990] trunk/blender/source/blender/ makesdna/intern/makesdna.c: fix for a (probably harmless) bug in makesdna where 1 byte off the end of the buffer was used in a comparison .

Campbell Barton ideasman42 at gmail.com
Sat Sep 18 05:46:14 CEST 2010


Revision: 31990
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31990
Author:   campbellbarton
Date:     2010-09-18 05:46:13 +0200 (Sat, 18 Sep 2010)

Log Message:
-----------
fix for a (probably harmless) bug in makesdna where 1 byte off the end of the buffer was used in a comparison.
also fixed a memory leak.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/intern/makesdna.c

Modified: trunk/blender/source/blender/makesdna/intern/makesdna.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/makesdna.c	2010-09-18 00:50:13 UTC (rev 31989)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c	2010-09-18 03:46:13 UTC (rev 31990)
@@ -421,7 +421,11 @@
 	int a, newlen, comment = 0;
 	char *cp, *temp, *md;
 	
-	temp= MEM_mallocN(len, "preprocess_include");
+	/* note: len + 1, last character is a dummy to prevent
+	 * comparisons using uninitialized memory */
+	temp= MEM_mallocN(len + 1, "preprocess_include");
+	temp[len]= ' ';
+
 	memcpy(temp, maindata, len);
 	
 	// remove all c++ comments
@@ -1054,6 +1058,7 @@
 	MEM_freeN(names);
 	MEM_freeN(types);
 	MEM_freeN(typelens);
+    MEM_freeN(alphalens);
 	MEM_freeN(structs);
 
 	if (debugSDNA > -1) printf("done.\n");





More information about the Bf-blender-cvs mailing list