diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-12 21:30:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-12 21:30:21 +0400 |
commit | 971e4be1081fb655f80d6d4065c734ccf625c987 (patch) | |
tree | be6d53d9712d5c51ef5e34f707c92274991c7439 /source/blender/makesrna/intern/rna_access.c | |
parent | c3c6fb2de28de350784db4730ed091da6b064198 (diff) |
modify my last commit to fix [#22486] add_actuator crashes when name is bigger than 32 chars
Throwing an exception if the strings too long means scripts need to be aware of string lengths and changing a string length in RNA can too easily break scripts.
Instead honor the string length in RNA_property_string_set()
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 75980e52206..4673f23b1ae 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -961,7 +961,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value) } /* this is the max length including \0 terminator. - * -1 used when their is no maximum */ + * '0' used when their is no maximum */ int RNA_property_string_maxlength(PropertyRNA *prop) { StringPropertyRNA *sprop= (StringPropertyRNA*)rna_ensure_property(prop); @@ -1830,18 +1830,15 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val IDProperty *idprop; if((idprop=rna_idproperty_check(&prop, ptr))) - IDP_AssignString(idprop, (char*)value); + IDP_AssignString(idprop, (char*)value, RNA_property_string_maxlength(prop) - 1); else if(sprop->set) - sprop->set(ptr, value); + sprop->set(ptr, value); /* set function needs to clamp its self */ else if(prop->flag & PROP_EDITABLE) { - IDPropertyTemplate val = {0}; IDProperty *group; - val.str= (char*)value; - group= RNA_struct_idproperties(ptr, 1); if(group) - IDP_AddToGroup(group, IDP_New(IDP_STRING, val, (char*)prop->identifier)); + IDP_AddToGroup(group, IDP_NewString((char*)value, (char*)prop->identifier, RNA_property_string_maxlength(prop) - 1)); } } |