[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11943] trunk/blender/source/blender/ python/api2_2x/Pose.c: printing a pose' s bone dict was limited to 4096 characters otherwise it would crash.
Campbell Barton
cbarton at metavr.com
Wed Sep 5 06:17:55 CEST 2007
Revision: 11943
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11943
Author: campbellbarton
Date: 2007-09-05 06:17:55 +0200 (Wed, 05 Sep 2007)
Log Message:
-----------
printing a pose's bone dict was limited to 4096 characters otherwise it would crash.
malloc the string instead.
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Pose.c
Modified: trunk/blender/source/blender/python/api2_2x/Pose.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Pose.c 2007-09-05 01:02:03 UTC (rev 11942)
+++ trunk/blender/source/blender/python/api2_2x/Pose.c 2007-09-05 04:17:55 UTC (rev 11943)
@@ -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 @@
//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 @@
}
sprintf(buffer, "}]\n");
strcat(str,buffer);
+
+ MEM_freeN( str );
+
return PyString_FromString(str);
}
More information about the Bf-blender-cvs
mailing list