From d5e11d409f470934eb77da194f1ee43df0ff7ac2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Sep 2010 03:46:13 +0000 Subject: 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. --- source/blender/makesdna/intern/makesdna.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 4133afffeed..577b18556c8 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -421,7 +421,11 @@ int preprocess_include(char *maindata, int len) 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 @@ int make_structDNA(char *baseDirectory, FILE *file) MEM_freeN(names); MEM_freeN(types); MEM_freeN(typelens); + MEM_freeN(alphalens); MEM_freeN(structs); if (debugSDNA > -1) printf("done.\n"); -- cgit v1.2.3