mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-27 14:03:36 +03:00
valid: Fix id handling in xmlValidateDtd
Free id table before and after validation.
This commit is contained in:
parent
c4e0db6a9e
commit
a3e11e3de1
27
valid.c
27
valid.c
@ -6403,18 +6403,15 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
|
|||||||
xmlDtdPtr oldExt, oldInt;
|
xmlDtdPtr oldExt, oldInt;
|
||||||
xmlNodePtr root;
|
xmlNodePtr root;
|
||||||
|
|
||||||
if (dtd == NULL) return(0);
|
if (dtd == NULL)
|
||||||
if (doc == NULL) return(0);
|
return(0);
|
||||||
|
if (doc == NULL)
|
||||||
|
return(0);
|
||||||
|
|
||||||
oldExt = doc->extSubset;
|
oldExt = doc->extSubset;
|
||||||
oldInt = doc->intSubset;
|
oldInt = doc->intSubset;
|
||||||
doc->extSubset = dtd;
|
doc->extSubset = dtd;
|
||||||
doc->intSubset = NULL;
|
doc->intSubset = NULL;
|
||||||
ret = xmlValidateRoot(ctxt, doc);
|
|
||||||
if (ret == 0) {
|
|
||||||
doc->extSubset = oldExt;
|
|
||||||
doc->intSubset = oldInt;
|
|
||||||
return(ret);
|
|
||||||
}
|
|
||||||
if (doc->ids != NULL) {
|
if (doc->ids != NULL) {
|
||||||
xmlFreeIDTable(doc->ids);
|
xmlFreeIDTable(doc->ids);
|
||||||
doc->ids = NULL;
|
doc->ids = NULL;
|
||||||
@ -6423,11 +6420,25 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
|
|||||||
xmlFreeRefTable(doc->refs);
|
xmlFreeRefTable(doc->refs);
|
||||||
doc->refs = NULL;
|
doc->refs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = xmlValidateRoot(ctxt, doc);
|
||||||
|
if (ret != 0) {
|
||||||
root = xmlDocGetRootElement(doc);
|
root = xmlDocGetRootElement(doc);
|
||||||
ret = xmlValidateElement(ctxt, doc, root);
|
ret = xmlValidateElement(ctxt, doc, root);
|
||||||
ret &= xmlValidateDocumentFinal(ctxt, doc);
|
ret &= xmlValidateDocumentFinal(ctxt, doc);
|
||||||
|
}
|
||||||
|
|
||||||
doc->extSubset = oldExt;
|
doc->extSubset = oldExt;
|
||||||
doc->intSubset = oldInt;
|
doc->intSubset = oldInt;
|
||||||
|
if (doc->ids != NULL) {
|
||||||
|
xmlFreeIDTable(doc->ids);
|
||||||
|
doc->ids = NULL;
|
||||||
|
}
|
||||||
|
if (doc->refs != NULL) {
|
||||||
|
xmlFreeRefTable(doc->refs);
|
||||||
|
doc->refs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user