mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-28 23:14:57 +03:00
malloc-fail: Fix reallocation in xmlXIncludeNewRef
Avoid null deref. Found with libFuzzer, see #344.
This commit is contained in:
12
xinclude.c
12
xinclude.c
@@ -272,14 +272,18 @@ xmlXIncludeNewRef(xmlXIncludeCtxtPtr ctxt, const xmlChar *URI,
|
||||
}
|
||||
}
|
||||
if (ctxt->incNr >= ctxt->incMax) {
|
||||
ctxt->incMax *= 2;
|
||||
ctxt->incTab = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
|
||||
ctxt->incMax * sizeof(ctxt->incTab[0]));
|
||||
if (ctxt->incTab == NULL) {
|
||||
xmlXIncludeRefPtr *tmp;
|
||||
size_t newSize = ctxt->incMax * 2;
|
||||
|
||||
tmp = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
|
||||
newSize * sizeof(ctxt->incTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
|
||||
xmlXIncludeFreeRef(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->incTab = tmp;
|
||||
ctxt->incMax *= 2;
|
||||
}
|
||||
ctxt->incTab[ctxt->incNr++] = ret;
|
||||
return(ret);
|
||||
|
||||
Reference in New Issue
Block a user