Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-11 09:45:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-11 09:45:59 +0400
commit93e4de755243f7f8b839375d4dd4f75965198334 (patch)
treecfa9db7e1451bf12794b7473e48dd6a43c9e9233 /source/blender/python
parent85a2280c861122da70a26da0c664bc1c4615efcd (diff)
fix for py/rna assigning an invalid index. also give better error message in this case.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index f5ecf91305d..ba7e2d41e69 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1928,10 +1928,10 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
}
+/* notice getting the length of the collection is avoided unless negative
+ * index is used or to detect internal error with a valid index.
+ * This is done for faster lookups. */
#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \
- /* notice getting the length of the collection is avoided unless negative \
- * index is used or to detect internal error with a valid index. \
- * This is done for faster lookups. */ \
if(keynum < 0) { \
keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \
if(keynum_abs < 0) { \
@@ -1984,11 +1984,18 @@ static int pyrna_prop_collection_ass_subscript_int(BPy_PropertyRNA *self, Py_ssi
PYRNA_PROP_COLLECTION_ABS_INDEX(-1);
if(RNA_property_collection_assign_int(&self->ptr, self->prop, keynum_abs, ptr) == 0) {
+ const int len= RNA_property_collection_length(&self->ptr, self->prop);
+ if(keynum_abs >= len) {
+ PyErr_Format(PyExc_IndexError,
+ "bpy_prop_collection[index] = value: "
+ "index %d out of range, size %d", keynum, len);
+ }
+ else {
- PyErr_Format(PyExc_IndexError,
- "bpy_prop_collection[index] = value: "
- "failed assignment (unknown reason)", keynum);
-
+ PyErr_Format(PyExc_IndexError,
+ "bpy_prop_collection[index] = value: "
+ "failed assignment (unknown reason)", keynum);
+ }
return -1;
}