diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-15 05:31:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-15 05:31:58 +0400 |
commit | 77a15aba38f00cd2694bb7c463057cada0690e50 (patch) | |
tree | f87b867a1c0c334fa44a74615c9e749ceb3974a6 /source | |
parent | 15969fba1f151a370dd2a74d9fa811704ab0eb53 (diff) |
IDProp API: change IDP_NewString so `sizeof()` can be passed in.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 0596c5109dd..603ddf7ac2e 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -334,13 +334,12 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) prop->len = 1; /* NULL string, has len of 1 to account for null byte. */ } else { - int stlen = strlen(st); + /* include null terminator '\0' */ + int stlen = strlen(st) + 1; if (maxlen > 0 && maxlen < stlen) stlen = maxlen; - stlen++; /* null terminator '\0' */ - prop->data.pointer = MEM_mallocN(stlen, "id property string 2"); prop->len = prop->totallen = stlen; BLI_strncpy(prop->data.pointer, st, stlen); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7946d24b83b..a3dee924c0b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2594,7 +2594,7 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val group = RNA_struct_idprops(ptr, 1); if (group) - IDP_AddToGroup(group, IDP_NewString(value, prop->identifier, RNA_property_string_maxlength(prop) - 1)); + IDP_AddToGroup(group, IDP_NewString(value, prop->identifier, RNA_property_string_maxlength(prop))); } } |