[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55075] trunk/blender/source/blender/ makesrna/intern/rna_access.c: add asserts for passing negative index values to RNA functions which don' t support them.

Campbell Barton ideasman42 at gmail.com
Wed Mar 6 16:38:12 CET 2013


Revision: 55075
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55075
Author:   campbellbarton
Date:     2013-03-06 15:38:11 +0000 (Wed, 06 Mar 2013)
Log Message:
-----------
add asserts for passing negative index values to RNA functions which don't support them.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_access.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-03-06 03:58:38 UTC (rev 55074)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2013-03-06 15:38:11 UTC (rev 55075)
@@ -845,6 +845,8 @@
 	const char *coloritem = "RGBA";
 	PropertySubType subtype = rna_ensure_property(prop)->subtype;
 
+	BLI_assert(index >= 0);
+
 	/* get string to use for array index */
 	if ((index < 4) && ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) {
 		return quatitem[index];
@@ -1440,6 +1442,8 @@
 	ID *id;
 	int flag;
 
+	BLI_assert(index >= 0);
+
 	prop = rna_ensure_property(prop);
 
 	flag = prop->flag;
@@ -1748,6 +1752,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_boolean_get_array(ptr, prop, tmp);
@@ -1810,6 +1815,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_boolean_get_array(ptr, prop, tmp);
@@ -1859,6 +1865,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_boolean_get_default_array(ptr, prop, tmp);
@@ -1996,6 +2003,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_INT);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_int_get_array(ptr, prop, tmp);
@@ -2060,6 +2068,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_INT);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_int_get_array(ptr, prop, tmp);
@@ -2103,6 +2112,10 @@
 	int tmp[RNA_MAX_ARRAY_LENGTH];
 	int len = rna_ensure_property_array_length(ptr, prop);
 
+	BLI_assert(RNA_property_type(prop) == PROP_INT);
+	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
+
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_int_get_default_array(ptr, prop, tmp);
 		return tmp[index];
@@ -2255,6 +2268,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_float_get_array(ptr, prop, tmp);
@@ -2270,7 +2284,6 @@
 
 		return value;
 	}
-
 }
 
 void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
@@ -2332,6 +2345,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_float_get_array(ptr, prop, tmp);
@@ -2381,6 +2395,7 @@
 
 	BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
 	BLI_assert(RNA_property_array_check(prop) != 0);
+	BLI_assert(index >= 0);
 
 	if (len <= RNA_MAX_ARRAY_LENGTH) {
 		RNA_property_float_get_default_array(ptr, prop, tmp);




More information about the Bf-blender-cvs mailing list