1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-23 02:50:08 +03:00

SAX2: Check return value of xmlPushInput

Fix null deref in case of malloc failure.
This commit is contained in:
Nick Wellnhofer 2024-07-06 15:15:57 +02:00
parent 38195cf596
commit 1e5375c1b4
2 changed files with 7 additions and 10 deletions

14
SAX2.c
View File

@ -320,18 +320,13 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
xmlMalloc(5 * sizeof(xmlParserInputPtr));
if (ctxt->inputTab == NULL) {
xmlSAX2ErrMemory(ctxt);
xmlFreeInputStream(input);
ctxt->input = oldinput;
ctxt->inputNr = oldinputNr;
ctxt->inputMax = oldinputMax;
ctxt->inputTab = oldinputTab;
ctxt->encoding = oldencoding;
return;
goto error;
}
ctxt->inputNr = 0;
ctxt->inputMax = 5;
ctxt->input = NULL;
xmlPushInput(ctxt, input);
if (xmlPushInput(ctxt, input) < 0)
goto error;
if (input->filename == NULL)
input->filename = (char *) xmlCanonicPath(SystemID);
@ -364,7 +359,8 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
else
ctxt->sizeentities += consumed;
xmlFreeInputStream(ctxt->input);
error:
xmlFreeInputStream(input);
xmlFree(ctxt->inputTab);
/*

View File

@ -2564,7 +2564,8 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
return(-1);
}
ret = inputPush(ctxt, input);
GROW;
if (ret >= 0)
GROW;
return(ret);
}