GNOME Bugzilla – Bug 320540
bad xmlFree in libxslt Python accessor functions - memory corruption, segfaults
Last modified: 2006-10-12 08:26:14 UTC
Originally reported by: Josh Triplett <josh@freedesktop.org> in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=326982 Several Python accessor functions for string fields of libxslt structures call libxml_xmlCharPtrWrap to wrap the 'xmlChar *' in a Python string object, which calls xmlFree on the field after creating the Python string from it; this leads to memory corruption and segfaults. The attached patch modifies the API description XML file to mark these return values as "const xmlChar *" rather than "xmlChar *" so that the generated accessor functions call libxml_constxmlCharPtrWrap instead, which does not call xmlFree. diff -Naur libxslt-1.1.14.old/python/libxslt-python-api.xml libxslt-1.1.14/python/libxslt-python-api.xml --- libxslt-1.1.14.old/python/libxslt-python-api.xml 2004-07-13 08:43:19.000000000 -0700 +++ libxslt-1.1.14/python/libxslt-python-api.xml 2005-09-06 15:24:56.000000000 -0700 @@ -141,22 +141,22 @@ </function> <function name='xsltStylesheetGetMethod' file='python_accessor'> <info>Get the output method of a stylesheet</info> - <return type='xmlChar *' info="The output method" field="method"/> + <return type='const xmlChar *' info="The output method" field="method"/> <arg name='style' type='xsltStylesheetPtr' info='the stylesheet'/> </function> <function name='xsltStylesheetGetMethodURI' file='python_accessor'> <info>Get the output method URI of a stylesheet</info> - <return type='xmlChar *' info="The output method URI" field="methodURI"/> + <return type='const xmlChar *' info="The output method URI" field="methodURI"/> <arg name='style' type='xsltStylesheetPtr' info='the stylesheet'/> </function> <function name='xsltStylesheetGetVersion' file='python_accessor'> <info>Get the output version of a stylesheet</info> - <return type='xmlChar *' info="The output version" field="version"/> + <return type='const xmlChar *' info="The output version" field="version"/> <arg name='style' type='xsltStylesheetPtr' info='the stylesheet'/> </function> <function name='xsltStylesheetGetEncoding' file='python_accessor'> <info>Get the output encoding of a stylesheet</info> - <return type='xmlChar *' info="The output encoding" field="encoding"/> + <return type='const xmlChar *' info="The output encoding" field="encoding"/> <arg name='style' type='xsltStylesheetPtr' info='the stylesheet'/> </function> <function name='xsltStylesheetGetDoctypePublic' file='python_accessor'>
hello ?
is it going to be fixed ?
very likely, I just didn't remember about it, adding the patch as an attachement would make more obvious that a patch is available, and hence easilly fixeable. Looked at it briefly, yes that's right, and need fixing, and the patch looks just fine. Daniel
Okay, done, it's commited in CVS, thanks ! Daniel