mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-13 13:17: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;
|
||||
xmlNodePtr root;
|
||||
|
||||
if (dtd == NULL) return(0);
|
||||
if (doc == NULL) return(0);
|
||||
if (dtd == NULL)
|
||||
return(0);
|
||||
if (doc == NULL)
|
||||
return(0);
|
||||
|
||||
oldExt = doc->extSubset;
|
||||
oldInt = doc->intSubset;
|
||||
doc->extSubset = dtd;
|
||||
doc->intSubset = NULL;
|
||||
ret = xmlValidateRoot(ctxt, doc);
|
||||
if (ret == 0) {
|
||||
doc->extSubset = oldExt;
|
||||
doc->intSubset = oldInt;
|
||||
return(ret);
|
||||
}
|
||||
if (doc->ids != NULL) {
|
||||
xmlFreeIDTable(doc->ids);
|
||||
doc->ids = NULL;
|
||||
@ -6423,11 +6420,25 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
|
||||
xmlFreeRefTable(doc->refs);
|
||||
doc->refs = NULL;
|
||||
}
|
||||
|
||||
ret = xmlValidateRoot(ctxt, doc);
|
||||
if (ret != 0) {
|
||||
root = xmlDocGetRootElement(doc);
|
||||
ret = xmlValidateElement(ctxt, doc, root);
|
||||
ret &= xmlValidateDocumentFinal(ctxt, doc);
|
||||
}
|
||||
|
||||
doc->extSubset = oldExt;
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user