diff options
-rw-r--r-- | source/blender/python/api2_2x/Pose.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/Pose.c b/source/blender/python/api2_2x/Pose.c index 67a1f222ea6..ed25c15c9f5 100644 --- a/source/blender/python/api2_2x/Pose.c +++ b/source/blender/python/api2_2x/Pose.c @@ -57,6 +57,8 @@ #include "DNA_armature_types.h" /*used for pose bone select*/ +#include "MEM_guardedalloc.h" + extern void chan_calc_mat(bPoseChannel *chan); //------------------------ERROR CODES--------------------------------- @@ -143,11 +145,14 @@ static int PoseBonesDict_InitBones(BPy_PoseBonesDict *self) //This is the string representation of the object static PyObject *PoseBonesDict_repr(BPy_PoseBonesDict *self) { - char buffer[128], str[4096]; + char buffer[128], *str; PyObject *key, *value; int pos = 0; - - BLI_strncpy(str,"",4096); + + /* probably a bit of overkill but better then crashing */ + str = MEM_mallocN( 64 + ( PyDict_Size( self->bonesMap ) * 128), "PoseBonesDict_repr" ); + str[0] = '\0'; + sprintf(buffer, "[Pose Bone Dict: {"); strcat(str,buffer); while (PyDict_Next(self->bonesMap, &pos, &key, &value)) { @@ -157,6 +162,9 @@ static PyObject *PoseBonesDict_repr(BPy_PoseBonesDict *self) } sprintf(buffer, "}]\n"); strcat(str,buffer); + + MEM_freeN( str ); + return PyString_FromString(str); } |