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
diff options
context:
space:
mode:
authorKen Hughes <khughes@pacific.edu>2006-07-14 18:48:45 +0400
committerKen Hughes <khughes@pacific.edu>2006-07-14 18:48:45 +0400
commita33bd50108bbbb51cbffd1fb81a20dfe2477ccaf (patch)
tree00a0dbd0df0176d24d2c5ce89a017469cb32f356
parenta7b3203e31c74c2829a9a2bf3009bba1bcc8ac9d (diff)
===Python API===v2.42
Bugfix #4690: BonesDict_repr() had a string overflow for really complicated armatures. Added a string length check and terminate before overflowing.
-rw-r--r--source/blender/python/api2_2x/Armature.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index 1504cff1dcf..bae9b1b0db4 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -170,25 +170,38 @@ static int BonesDict_InitEditBones(BPy_BonesDict *self)
//This is the string representation of the object
static PyObject *BonesDict_repr(BPy_BonesDict *self)
{
- char str[4096];
+ char str[2048];
PyObject *key, *value;
int pos = 0;
char *p = str;
+ char *keys, *vals;
p += sprintf(str, "[Bone Dict: {");
if (self->editmode_flag){
while (PyDict_Next(self->editbonesMap, &pos, &key, &value)) {
- p += sprintf(p, "%s : %s, ", PyString_AsString(key),
- PyString_AsString(value->ob_type->tp_repr(value)));
+ keys = PyString_AsString(key);
+ vals = PyString_AsString(value->ob_type->tp_repr(value));
+ if( strlen(str) + strlen(keys) + strlen(vals) < sizeof(str)-20 )
+ p += sprintf(p, "%s : %s, ", keys, vals );
+ else {
+ p += sprintf(p, "...." );
+ break;
+ }
}
}else{
while (PyDict_Next(self->bonesMap, &pos, &key, &value)) {
- p += sprintf(p, "%s : %s, ", PyString_AsString(key),
- PyString_AsString(value->ob_type->tp_repr(value)));
+ keys = PyString_AsString(key);
+ vals = PyString_AsString(value->ob_type->tp_repr(value));
+ if( strlen(str) + strlen(keys) + strlen(vals) < sizeof(str)-20 )
+ p += sprintf(p, "%s : %s, ", keys, vals );
+ else {
+ p += sprintf(p, "...." );
+ break;
+ }
}
}
- p += sprintf(p, "}]\n");
+ sprintf(p, "}]");
return PyString_FromString(str);
}