diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2004-03-06 13:35:15 +0300 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2004-03-06 13:35:15 +0300 |
commit | 7b5d3f183b421ad8c1d223d563f5375e4ad1afcc (patch) | |
tree | e28ffaa9e90f601284921b1f8c70748e5eee9b11 /source | |
parent | 8a7110a19a2eb753c1a4cc8117e7da763a959bf0 (diff) |
Fix for bug# 986
Assigning a new value to a Button string did not resize the string buffer.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 19f2d2f8807..475088de9e3 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -79,9 +79,20 @@ static int Button_setattr(PyObject *self, char *name, PyObject *v) PyArg_Parse(v, "f", &but->val.asfloat); else if (but->type==3) { char *newstr; - PyArg_Parse(v, "s", &newstr); - strncpy(but->val.asstr, newstr, but->slen); + + /* if the length of the new string is the same as */ + /* the old one, just copy, else delete and realloc. */ + if( but->slen == strlen( newstr) ) { + strncpy(but->val.asstr, newstr, but->slen); + } + else { + MEM_freeN( but->val.asstr); + but->slen = strlen( newstr ); + but->val.asstr = MEM_mallocN( but->slen + 1, + "button setattr"); + strcpy( but->val.asstr, newstr ); + } } } else { PyErr_SetString(PyExc_AttributeError, name); |