diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-18 07:46:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-18 07:46:13 +0400 |
commit | d5e11d409f470934eb77da194f1ee43df0ff7ac2 (patch) | |
tree | 367c9b627c548663362606ce0d0a945806c41472 /source/blender/makesdna | |
parent | 3e1ff2e590970c6db02859df0f73531692767cbf (diff) |
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.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 7 |
1 files changed, 6 insertions, 1 deletions
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"); |