mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-27 14:03:36 +03:00
malloc-fail: Fix memory leak in xmlSchemaItemListAddSize
Found with libFuzzer, see #344.
This commit is contained in:
parent
0263b35756
commit
ba290a8663
@ -3448,14 +3448,17 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list,
|
||||
}
|
||||
list->sizeItems = initialSize;
|
||||
} else if (list->sizeItems <= list->nbItems) {
|
||||
void **tmp;
|
||||
|
||||
list->sizeItems *= 2;
|
||||
list->items = (void **) xmlRealloc(list->items,
|
||||
tmp = (void **) xmlRealloc(list->items,
|
||||
list->sizeItems * sizeof(void *));
|
||||
if (list->items == NULL) {
|
||||
if (tmp == NULL) {
|
||||
xmlSchemaPErrMemory(NULL, "growing item list", NULL);
|
||||
list->sizeItems = 0;
|
||||
list->sizeItems /= 2;
|
||||
return(-1);
|
||||
}
|
||||
list->items = tmp;
|
||||
}
|
||||
list->items[list->nbItems++] = item;
|
||||
return(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user