Change clear_handlers argument to indicate whether this is an initialization.
Do not set the Expat handlers if it is. Fixes PyXML bug #473195.
This commit is contained in:
parent
6d204074cb
commit
5b68ce3122
|
@ -290,12 +290,12 @@ conv_string_len_to_utf8(const XML_Char *str, int len)
|
||||||
|
|
||||||
/* Callback routines */
|
/* Callback routines */
|
||||||
|
|
||||||
static void clear_handlers(xmlparseobject *self, int decref);
|
static void clear_handlers(xmlparseobject *self, int initial);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flag_error(xmlparseobject *self)
|
flag_error(xmlparseobject *self)
|
||||||
{
|
{
|
||||||
clear_handlers(self, 1);
|
clear_handlers(self, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyCodeObject*
|
static PyCodeObject*
|
||||||
|
@ -1017,7 +1017,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
|
||||||
Py_DECREF(new_parser);
|
Py_DECREF(new_parser);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
clear_handlers(new_parser, 0);
|
clear_handlers(new_parser, 1);
|
||||||
|
|
||||||
/* then copy handlers from self */
|
/* then copy handlers from self */
|
||||||
for (i = 0; handler_info[i].name != NULL; i++) {
|
for (i = 0; handler_info[i].name != NULL; i++) {
|
||||||
|
@ -1193,7 +1193,7 @@ newxmlparseobject(char *encoding, char *namespace_separator)
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
clear_handlers(self, 0);
|
clear_handlers(self, 1);
|
||||||
|
|
||||||
return (PyObject*)self;
|
return (PyObject*)self;
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1367,7 @@ xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg)
|
||||||
static int
|
static int
|
||||||
xmlparse_clear(xmlparseobject *op)
|
xmlparse_clear(xmlparseobject *op)
|
||||||
{
|
{
|
||||||
clear_handlers(op, 1);
|
clear_handlers(op, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1676,21 +1676,22 @@ MODULE_INITFUNC(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_handlers(xmlparseobject *self, int decref)
|
clear_handlers(xmlparseobject *self, int initial)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
PyObject *temp;
|
PyObject *temp;
|
||||||
|
|
||||||
for (; handler_info[i].name!=NULL; i++) {
|
for (; handler_info[i].name!=NULL; i++) {
|
||||||
if (decref) {
|
if (initial)
|
||||||
|
self->handlers[i]=NULL;
|
||||||
|
else {
|
||||||
temp = self->handlers[i];
|
temp = self->handlers[i];
|
||||||
self->handlers[i] = NULL;
|
self->handlers[i] = NULL;
|
||||||
Py_XDECREF(temp);
|
Py_XDECREF(temp);
|
||||||
}
|
|
||||||
self->handlers[i]=NULL;
|
|
||||||
handler_info[i].setter(self->itself, NULL);
|
handler_info[i].setter(self->itself, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef void (*pairsetter)(XML_Parser, void *handler1, void *handler2);
|
typedef void (*pairsetter)(XML_Parser, void *handler1, void *handler2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue