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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-06-12 19:49:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-06-12 19:49:01 +0400
commitc3c6fb2de28de350784db4730ed091da6b064198 (patch)
tree5569a98c3d4dab27fa2d6728444051696e07e03d /source
parent33b624cb5ff28af208ad95c1cf6d64c45077eb50 (diff)
bugfix [#22486] add_actuator crashes when name is bigger than 32 chars
have pyrna raise an error on strings that are too long.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_access.c3
-rw-r--r--source/blender/python/intern/bpy_rna.c12
2 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 452d8d80dbc..75980e52206 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -960,7 +960,8 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
}
}
-/* this is the max length including \0 terminator */
+/* this is the max length including \0 terminator.
+ * -1 used when their is no maximum */
int RNA_property_string_maxlength(PropertyRNA *prop)
{
StringPropertyRNA *sprop= (StringPropertyRNA*)rna_ensure_property(prop);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 841cb75bc98..0d1bb64bac2 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -924,12 +924,18 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
}
case PROP_STRING:
{
- char *param = _PyUnicode_AsString(value);
-
+ Py_ssize_t param_len;
+ int param_maxlen= RNA_property_string_maxlength(prop) - 1;
+ char *param = _PyUnicode_AsStringAndSize(value, &param_len);
+
if (param==NULL) {
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
- } else {
+ } else if (param_maxlen != -1 && param_len > param_maxlen) { /* -1 because it includes the \0 */
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s string is length %d, expected maximum of %d", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), (int)param_len, param_maxlen);
+ return -1;
+ }
+ else {
if(data) *((char**)data)= param;
else RNA_property_string_set(ptr, prop, param);
}