1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

parser: Reenable ctxt->directory

Unused internally, but used in downstream code.

Should fix #753.
This commit is contained in:
Nick Wellnhofer 2024-07-02 21:54:26 +02:00
parent c127c89f98
commit fdfeecfe5e
3 changed files with 32 additions and 1 deletions

View File

@ -6184,6 +6184,12 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
ctxt->extSubURI = NULL;
DICT_FREE(ctxt->extSubSystem);
ctxt->extSubSystem = NULL;
if (ctxt->directory != NULL) {
xmlFree(ctxt->directory);
ctxt->directory = NULL;
}
if (ctxt->myDoc != NULL)
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;

View File

@ -1927,8 +1927,11 @@ mem_error:
int
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{
char *directory = NULL;
if ((ctxt == NULL) || (value == NULL))
return(-1);
if (ctxt->inputNr >= ctxt->inputMax) {
size_t newSize = ctxt->inputMax * 2;
xmlParserInputPtr *tmp;
@ -1942,9 +1945,24 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
ctxt->inputTab = tmp;
ctxt->inputMax = newSize;
}
if ((ctxt->inputNr == 0) && (value->filename != NULL)) {
directory = xmlParserGetDirectory(value->filename);
if (directory == NULL) {
xmlErrMemory(ctxt);
return(-1);
}
}
ctxt->inputTab[ctxt->inputNr] = value;
ctxt->input = value;
return (ctxt->inputNr++);
if (ctxt->inputNr == 0) {
xmlFree(ctxt->directory);
ctxt->directory = directory;
}
return(ctxt->inputNr++);
}
/**
* inputPop:
@ -13299,6 +13317,12 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->extSubURI = NULL;
DICT_FREE(ctxt->extSubSystem);
ctxt->extSubSystem = NULL;
if (ctxt->directory != NULL) {
xmlFree(ctxt->directory);
ctxt->directory = NULL;
}
if (ctxt->myDoc != NULL)
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;

View File

@ -2894,6 +2894,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->sax != NULL)
#endif /* LIBXML_SAX1_ENABLED */
xmlFree(ctxt->sax);
if (ctxt->directory != NULL) xmlFree(ctxt->directory);
if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts);
if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);