Commit a2d51fc3 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixing bug #141384 where the reader didn't call the deregistering

* xmllint.c xmlreader.c: fixing bug #141384 where the reader didn't
  call the deregistering functions. Also added the check to
  xmllint --stream --chkregister .
Daniel
parent 712096b3
Fri Apr 30 18:12:31 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xmllint.c xmlreader.c: fixing bug #141384 where the reader didn't
call the deregistering functions. Also added the check to
xmllint --stream --chkregister .
Fri Apr 30 08:57:47 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
* win32/Makefile.msvc: applied a second patch from Mark Vakoc for
......
......@@ -160,6 +160,7 @@ static int stream = 0;
static int walker = 0;
#endif /* LIBXML_READER_ENABLED */
static int chkregister = 0;
static int nbregister = 0;
#ifdef LIBXML_SAX1_ENABLED
static int sax1 = 0;
#endif /* LIBXML_SAX1_ENABLED */
......@@ -1517,6 +1518,7 @@ static void registerNode(xmlNodePtr node)
{
node->_private = malloc(sizeof(long));
*(long*)node->_private = (long) 0x81726354;
nbregister++;
}
static void deregisterNode(xmlNodePtr node)
......@@ -1524,6 +1526,7 @@ static void deregisterNode(xmlNodePtr node)
assert(node->_private != NULL);
assert(*(long*)node->_private == (long) 0x81726354);
free(node->_private);
nbregister--;
}
int
......@@ -1975,12 +1978,19 @@ main(int argc, char **argv) {
if (ctxt != NULL)
xmlFreeParserCtxt(ctxt);
} else {
nbregister = 0;
#ifdef LIBXML_READER_ENABLED
if (stream != 0)
streamFile(argv[i]);
else
#endif /* LIBXML_READER_ENABLED */
parseAndPrintFile(argv[i], NULL);
if ((chkregister) && (nbregister != 0)) {
fprintf(stderr, "Registration count off: %d\n", nbregister);
progresult = 8;
}
}
files ++;
if ((timing) && (repeat)) {
......
......@@ -255,6 +255,9 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
dict = reader->ctxt->dict;
if (cur == NULL) return;
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
xmlDeregisterNodeDefaultValue((xmlNodePtr) cur);
/* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL) &&
((cur->parent->doc->intSubset != NULL) ||
......@@ -329,6 +332,10 @@ xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlTextReaderFreeNodeList(reader, cur->children);
cur->children = NULL;
}
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
xmlDeregisterNodeDefaultValue(cur);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
......@@ -399,6 +406,10 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlTextReaderFreeNodeList(reader, cur->children);
cur->children = NULL;
}
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
xmlDeregisterNodeDefaultValue(cur);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
(cur->type == XML_XINCLUDE_END)) &&
......@@ -422,6 +433,7 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
if ((cur->type != XML_TEXT_NODE) &&
(cur->type != XML_COMMENT_NODE))
DICT_FREE(cur->name);
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE)) &&
(reader != NULL) && (reader->ctxt != NULL) &&
......@@ -458,6 +470,9 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
if (cur == NULL) return;
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
xmlDeregisterNodeDefaultValue((xmlNodePtr) cur);
/*
* Do this before freeing the children list to avoid ID lookups
*/
......@@ -488,6 +503,7 @@ xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) {
if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs);
if (cur->URL != NULL) xmlFree((char *) cur->URL);
if (cur->dict != NULL) xmlDictFree(cur->dict);
xmlFree(cur);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment