forked from bartvdbraak/blender
Fixing a bit of horrible code in Armature.c (BonesDict_repr).
There is a lot of very dangerous (and slow) string manipulation code in there. I do not want to appear arrogant, but a bit of basic code QA in this module certainly can't hurt. Please see the diff for further explanation ;-)
This commit is contained in:
parent
e8f7ff2ffb
commit
6f10660f0c
@ -172,28 +172,25 @@ static int BonesDict_InitEditBones(BPy_BonesDict *self)
|
||||
//This is the string representation of the object
|
||||
static PyObject *BonesDict_repr(BPy_BonesDict *self)
|
||||
{
|
||||
char buffer[128], str[4096];
|
||||
char str[4096];
|
||||
PyObject *key, *value;
|
||||
int pos = 0;
|
||||
char *p = str;
|
||||
|
||||
p += sprintf(str, "[Bone Dict: {");
|
||||
|
||||
BLI_strncpy(str,"",4096);
|
||||
sprintf(buffer, "[Bone Dict: {");
|
||||
strcat(str,buffer);
|
||||
if (self->editmode_flag){
|
||||
while (PyDict_Next(self->editbonesMap, &pos, &key, &value)) {
|
||||
sprintf(buffer, "%s : %s, ", PyString_AsString(key),
|
||||
p += sprintf(p, "%s : %s, ", PyString_AsString(key),
|
||||
PyString_AsString(value->ob_type->tp_repr(value)));
|
||||
strcat(str,buffer);
|
||||
}
|
||||
}else{
|
||||
while (PyDict_Next(self->bonesMap, &pos, &key, &value)) {
|
||||
sprintf(buffer, "%s : %s, ", PyString_AsString(key),
|
||||
p += sprintf(p, "%s : %s, ", PyString_AsString(key),
|
||||
PyString_AsString(value->ob_type->tp_repr(value)));
|
||||
strcat(str,buffer);
|
||||
}
|
||||
}
|
||||
sprintf(buffer, "}]\n");
|
||||
strcat(str,buffer);
|
||||
p += sprintf(p, "}]\n");
|
||||
return PyString_FromString(str);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user