1
0
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:
Nick Wellnhofer 2024-03-01 15:55:35 +01:00
parent c4e0db6a9e
commit a3e11e3de1

41
valid.c
View File

@ -6403,31 +6403,42 @@ 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;
xmlFreeIDTable(doc->ids);
doc->ids = NULL;
}
if (doc->refs != NULL) {
xmlFreeRefTable(doc->refs);
doc->refs = NULL;
xmlFreeRefTable(doc->refs);
doc->refs = NULL;
}
root = xmlDocGetRootElement(doc);
ret = xmlValidateElement(ctxt, doc, root);
ret &= xmlValidateDocumentFinal(ctxt, doc);
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);
}