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:
authorStephen Swaney <sswaney@centurytel.net>2004-03-06 13:35:15 +0300
committerStephen Swaney <sswaney@centurytel.net>2004-03-06 13:35:15 +0300
commit7b5d3f183b421ad8c1d223d563f5375e4ad1afcc (patch)
treee28ffaa9e90f601284921b1f8c70748e5eee9b11 /source
parent8a7110a19a2eb753c1a4cc8117e7da763a959bf0 (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.c15
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);