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) {
|
if (ctxt->incNr >= ctxt->incMax) {
|
||||||
ctxt->incMax *= 2;
|
xmlXIncludeRefPtr *tmp;
|
||||||
ctxt->incTab = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
|
size_t newSize = ctxt->incMax * 2;
|
||||||
ctxt->incMax * sizeof(ctxt->incTab[0]));
|
|
||||||
if (ctxt->incTab == NULL) {
|
tmp = (xmlXIncludeRefPtr *) xmlRealloc(ctxt->incTab,
|
||||||
|
newSize * sizeof(ctxt->incTab[0]));
|
||||||
|
if (tmp == NULL) {
|
||||||
xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
|
xmlXIncludeErrMemory(ctxt, elem, "growing XInclude context");
|
||||||
xmlXIncludeFreeRef(ret);
|
xmlXIncludeFreeRef(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
ctxt->incTab = tmp;
|
||||||
|
ctxt->incMax *= 2;
|
||||||
}
|
}
|
||||||
ctxt->incTab[ctxt->incNr++] = ret;
|
ctxt->incTab[ctxt->incNr++] = ret;
|
||||||
return(ret);
|
return(ret);
|
||||||
|
|||||||
Reference in New Issue
Block a user