summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-09-10 22:25:19 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-09-10 22:25:19 (GMT)
commitb4ba986a7170ab02059a149737928b00d30fa306 (patch)
tree7a614269b0207f847b44cfc2c2f660723e404526 /Modules/pyexpat.c
parent3d75d0cc9244a8c2c1f31deb47f097409d36fefb (diff)
downloadcpython-b4ba986a7170ab02059a149737928b00d30fa306.zip
cpython-b4ba986a7170ab02059a149737928b00d30fa306.tar.gz
cpython-b4ba986a7170ab02059a149737928b00d30fa306.tar.bz2
Issue #9402: pyexpat uses Py_DECREF() instead of PyObject_DEL()
Fix a crash if Python is compiled in pydebug mode.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 1653432..f24584c 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -973,21 +973,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
return NULL;
new_parser->buffer_size = self->buffer_size;
new_parser->buffer_used = 0;
- if (self->buffer != NULL) {
- new_parser->buffer = malloc(new_parser->buffer_size);
- if (new_parser->buffer == NULL) {
-#ifndef Py_TPFLAGS_HAVE_GC
- /* Code for versions 2.0 and 2.1 */
- PyObject_Del(new_parser);
-#else
- /* Code for versions 2.2 and later. */
- PyObject_GC_Del(new_parser);
-#endif
- return PyErr_NoMemory();
- }
- }
- else
- new_parser->buffer = NULL;
+ new_parser->buffer = NULL;
new_parser->ordered_attributes = self->ordered_attributes;
new_parser->specified_attributes = self->specified_attributes;
new_parser->in_callback = 0;
@@ -1003,6 +989,13 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
PyObject_GC_Init(new_parser);
#endif
+ if (self->buffer != NULL) {
+ new_parser->buffer = malloc(new_parser->buffer_size);
+ if (new_parser->buffer == NULL) {
+ Py_DECREF(new_parser);
+ return PyErr_NoMemory();
+ }
+ }
if (!new_parser->itself) {
Py_DECREF(new_parser);
return PyErr_NoMemory();