diff options
Diffstat (limited to 'source/blender/makesdna/intern/makesdna.c')
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 4f26a406dda..77092dacc06 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -671,6 +671,8 @@ int arraysize(char *astr, int len) } else if( str[a]==']' && cp) { str[a]= 0; + /* if 'cp' is a preprocessor definition, it will evaluate to 0, + * the caller needs to check for this case and throw an error */ mul*= atoi(cp); } } @@ -714,7 +716,12 @@ static int calculate_structlens(int firststruct) /* has the name an extra length? (array) */ mul= 1; if( cp[namelen-1]==']') mul= arraysize(cp, namelen); - + + if (mul == 0) { + printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp); + dna_error = 1; + } + /* 4-8 aligned/ */ if(sizeof(void *) == 4) { if (len % 4) { @@ -744,7 +751,12 @@ static int calculate_structlens(int firststruct) /* has the name an extra length? (array) */ mul= 1; if( cp[namelen-1]==']') mul= arraysize(cp, namelen); - + + if (mul == 0) { + printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp); + dna_error = 1; + } + /* struct alignment */ if(type >= firststruct) { if(sizeof(void *)==8 && (len % 8) ) { @@ -856,12 +868,13 @@ void dna_write(FILE *file, void *pntr, int size) void printStructLenghts(void) { - int a, unknown= nr_structs, lastunknown, structtype; + int a, unknown= nr_structs, structtype; + /*int lastunknown;*/ /*UNUSED*/ short *structpoin; printf("\n\n*** All detected structs:\n"); while(unknown) { - lastunknown= unknown; + /*lastunknown= unknown;*/ /*UNUSED*/ unknown= 0; /* check all structs... */ |