mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
Handle malloc failures in fuzzing code
Avoid misdiagnosis in OOM situations.
This commit is contained in:
@@ -211,6 +211,8 @@ xmlFuzzReadEntities(void) {
|
||||
|
||||
if (xmlHashLookup(fuzzData.entities, (xmlChar *)url) == NULL) {
|
||||
entityInfo = xmlMalloc(sizeof(xmlFuzzEntityInfo));
|
||||
if (entityInfo == NULL)
|
||||
break;
|
||||
entityInfo->data = entity;
|
||||
entityInfo->size = entitySize;
|
||||
|
||||
@@ -271,6 +273,10 @@ xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED,
|
||||
input->filename = NULL;
|
||||
input->buf = xmlParserInputBufferCreateMem(entity->data, entity->size,
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
if (input->buf == NULL) {
|
||||
xmlFreeInputStream(input);
|
||||
return(NULL);
|
||||
}
|
||||
input->base = input->cur = xmlBufContent(input->buf->buffer);
|
||||
input->end = input->base + entity->size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user