Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b68ce3

Browse files
committed
Change clear_handlers argument to indicate whether this is an initialization.
Do not set the Expat handlers if it is. Fixes PyXML bug #473195.
1 parent 6d20407 commit 5b68ce3

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Modules/pyexpat.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ conv_string_len_to_utf8(const XML_Char *str, int len)
290290

291291
/* Callback routines */
292292

293-
static void clear_handlers(xmlparseobject *self, int decref);
293+
static void clear_handlers(xmlparseobject *self, int initial);
294294

295295
static void
296296
flag_error(xmlparseobject *self)
297297
{
298-
clear_handlers(self, 1);
298+
clear_handlers(self, 0);
299299
}
300300

301301
static PyCodeObject*
@@ -1017,7 +1017,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
10171017
Py_DECREF(new_parser);
10181018
return PyErr_NoMemory();
10191019
}
1020-
clear_handlers(new_parser, 0);
1020+
clear_handlers(new_parser, 1);
10211021

10221022
/* then copy handlers from self */
10231023
for (i = 0; handler_info[i].name != NULL; i++) {
@@ -1193,7 +1193,7 @@ newxmlparseobject(char *encoding, char *namespace_separator)
11931193
Py_DECREF(self);
11941194
return PyErr_NoMemory();
11951195
}
1196-
clear_handlers(self, 0);
1196+
clear_handlers(self, 1);
11971197

11981198
return (PyObject*)self;
11991199
}
@@ -1367,7 +1367,7 @@ xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg)
13671367
static int
13681368
xmlparse_clear(xmlparseobject *op)
13691369
{
1370-
clear_handlers(op, 1);
1370+
clear_handlers(op, 0);
13711371
return 0;
13721372
}
13731373
#endif
@@ -1676,19 +1676,20 @@ MODULE_INITFUNC(void)
16761676
}
16771677

16781678
static void
1679-
clear_handlers(xmlparseobject *self, int decref)
1679+
clear_handlers(xmlparseobject *self, int initial)
16801680
{
16811681
int i = 0;
16821682
PyObject *temp;
16831683

16841684
for (; handler_info[i].name!=NULL; i++) {
1685-
if (decref) {
1685+
if (initial)
1686+
self->handlers[i]=NULL;
1687+
else {
16861688
temp = self->handlers[i];
16871689
self->handlers[i] = NULL;
16881690
Py_XDECREF(temp);
1691+
handler_info[i].setter(self->itself, NULL);
16891692
}
1690-
self->handlers[i]=NULL;
1691-
handler_info[i].setter(self->itself, NULL);
16921693
}
16931694
}
16941695

0 commit comments

Comments
 (0)