[issue9403] cElementTree: replace PyObject_DEL() by Py_DECREF() to fix a crash in pydebug mode
STINNER Victor
report at bugs.python.org
Wed Jul 28 22:58:25 CEST 2010
New submission from STINNER Victor <victor.stinner at haypocalc.com>:
PyObject_DEL() should not be used to destroy an object because it will break the linked list of allocated objects, list used in pydebug mode to detect bugs. cElementTree should use Py_DECREF() instead of PyObject_DEL() to destroy an objects.
Attached patch fixes that:
* Replace PyObject_Del() by Py_DECREF()
* Catch element_new_extra() errors
* parser dealloc: replace Py_DECREF() by Py_XDECREF() because the pointer may be NULL (error in the constructor)
* set all parser attributes to NULL at the beginning of the constructor to be able to call safetly the destructor
* element_new(): define tag, text, tail attributes before calling element_new_extra() to be able to call the destructor
* raise a MemoryError on element_new_extra() failure. element_new() didn't raise any error on element_new_extra() failure. Other functions just forget to catch element_new_extra() error.
See #3299 for the whole story.
----------
components: Library (Lib)
files: celementtree_py_decref.patch
keywords: patch
messages: 111846
nosy: haypo
priority: normal
severity: normal
status: open
title: cElementTree: replace PyObject_DEL() by Py_DECREF() to fix a crash in pydebug mode
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file18236/celementtree_py_decref.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9403>
_______________________________________
More information about the Python-bugs-list
mailing list