[XML-SIG] Bug in XML stuff?
Guido van Rossum
guido@CNRI.Reston.Va.US
Tue, 09 Jun 1998 11:03:37 -0400
After Jack isolated the bug approximately, I've found the problem.
There are two problems, really: (1) Han-Wen's code has a bug in his
Dimension.__str__() method: it never returns a value; (2) Python's
string formatting doesn't detect this, and ends up calling
memcpy(res, buf, len) with len being -1 and buf being NULL.
My apologies to Han-Wen. Here's a patch.
Index: stringobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.47
diff -c -r2.47 stringobject.c
*** stringobject.c 1998/04/10 22:16:39 2.47
--- stringobject.c 1998/06/09 15:01:53
***************
*** 900,905 ****
--- 900,910 ----
temp = PyObject_Str(v);
if (temp == NULL)
goto error;
+ if (!PyString_Check(temp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "%s argument has non-string str()");
+ goto error;
+ }
buf = PyString_AsString(temp);
len = PyString_Size(temp);
if (prec >= 0 && len > prec)
--Guido van Rossum (home page: http://www.python.org/~guido/)