[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37613] trunk/blender/source/blender/ makesdna/intern/makesdna.c: throw an error if preprocessor definitions are used for DNA array lengths (previously would fail silently & not work right).
Campbell Barton
ideasman42 at gmail.com
Sat Jun 18 05:14:27 CEST 2011
Revision: 37613
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37613
Author: campbellbarton
Date: 2011-06-18 03:14:24 +0000 (Sat, 18 Jun 2011)
Log Message:
-----------
throw an error if preprocessor definitions are used for DNA array lengths (previously would fail silently & not work right).
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 2011-06-18 00:47:59 UTC (rev 37612)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c 2011-06-18 03:14:24 UTC (rev 37613)
@@ -670,6 +670,8 @@
}
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);
}
}
@@ -713,7 +715,12 @@
/* 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) {
@@ -743,7 +750,12 @@
/* 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) ) {
More information about the Bf-blender-cvs
mailing list