mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-02-06 05:57:39 +03:00
malloc-fail: Fix reallocation in inputPush
Store xmlRealloc result in temporary variable to avoid null deref in error handler. Found with libFuzzer, see #344.
This commit is contained in:
parent
6fd8904108
commit
e6d22f925a
15
parser.c
15
parser.c
@ -1694,16 +1694,17 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
|
||||
if ((ctxt == NULL) || (value == NULL))
|
||||
return(-1);
|
||||
if (ctxt->inputNr >= ctxt->inputMax) {
|
||||
ctxt->inputMax *= 2;
|
||||
ctxt->inputTab =
|
||||
(xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
|
||||
ctxt->inputMax *
|
||||
sizeof(ctxt->inputTab[0]));
|
||||
if (ctxt->inputTab == NULL) {
|
||||
size_t newSize = ctxt->inputMax * 2;
|
||||
xmlParserInputPtr *tmp;
|
||||
|
||||
tmp = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
|
||||
newSize * sizeof(*tmp));
|
||||
if (tmp == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
ctxt->inputMax /= 2;
|
||||
return (-1);
|
||||
}
|
||||
ctxt->inputTab = tmp;
|
||||
ctxt->inputMax = newSize;
|
||||
}
|
||||
ctxt->inputTab[ctxt->inputNr] = value;
|
||||
ctxt->input = value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user