mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-19 14:50:07 +03:00
malloc-fail: Fix memory leak in xmlSchemaParseUnion
Also report malloc failure from xmlStrndup. Found with libFuzzer, see #344.
This commit is contained in:
parent
260d6b8d77
commit
961a4f35bf
@ -9032,6 +9032,11 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
if (end == cur)
|
||||
break;
|
||||
tmp = xmlStrndup(cur, end - cur);
|
||||
if (tmp == NULL) {
|
||||
xmlSchemaPErrMemory(ctxt, "xmlSchemaParseUnion, "
|
||||
"duplicating type name", NULL);
|
||||
return (-1);
|
||||
}
|
||||
if (xmlSchemaPValAttrNodeQNameValue(ctxt, schema,
|
||||
NULL, attr, BAD_CAST tmp, &nsName, &localName) == 0) {
|
||||
/*
|
||||
@ -9042,6 +9047,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
if (link == NULL) {
|
||||
xmlSchemaPErrMemory(ctxt, "xmlSchemaParseUnion, "
|
||||
"allocating a type link", NULL);
|
||||
FREE_AND_NULL(tmp)
|
||||
return (-1);
|
||||
}
|
||||
link->type = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user