mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
fix OOM handling in hash routines
* src/util/hash.c: virHashAddEntry and virHashUpdateEntry were missing NULL checks on strdup * AUTHORS: add Christophe Fergeau
This commit is contained in:
parent
eebf4dc343
commit
9190f0b0a0
1
AUTHORS
1
AUTHORS
@ -154,6 +154,7 @@ Patches have also been contributed by:
|
||||
Zdenek Styblik <stybla@turnovfree.net>
|
||||
Gui Jianfeng <guijianfeng@cn.fujitsu.com>
|
||||
Michal Novotny <minovotn@redhat.com>
|
||||
Christophe Fergeau <teuf@gnome.org>
|
||||
|
||||
[....send patches to get your name here....]
|
||||
|
||||
|
@ -253,6 +253,7 @@ virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
||||
unsigned long key, len = 0;
|
||||
virHashEntryPtr entry;
|
||||
virHashEntryPtr insert;
|
||||
char *new_name;
|
||||
|
||||
if ((table == NULL) || (name == NULL))
|
||||
return (-1);
|
||||
@ -281,12 +282,17 @@ virHashAddEntry(virHashTablePtr table, const char *name, void *userdata)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
entry->name = strdup(name);
|
||||
new_name = strdup(name);
|
||||
if (new_name == NULL) {
|
||||
if (insert != NULL)
|
||||
VIR_FREE(entry);
|
||||
return (-1);
|
||||
}
|
||||
entry->name = new_name;
|
||||
entry->payload = userdata;
|
||||
entry->next = NULL;
|
||||
entry->valid = 1;
|
||||
|
||||
|
||||
if (insert != NULL)
|
||||
insert->next = entry;
|
||||
|
||||
@ -318,6 +324,7 @@ virHashUpdateEntry(virHashTablePtr table, const char *name,
|
||||
unsigned long key;
|
||||
virHashEntryPtr entry;
|
||||
virHashEntryPtr insert;
|
||||
char *new_name;
|
||||
|
||||
if ((table == NULL) || name == NULL)
|
||||
return (-1);
|
||||
@ -353,7 +360,13 @@ virHashUpdateEntry(virHashTablePtr table, const char *name,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
entry->name = strdup(name);
|
||||
new_name= strdup(name);
|
||||
if (new_name == NULL) {
|
||||
if (insert != NULL)
|
||||
VIR_FREE(entry);
|
||||
return (-1);
|
||||
}
|
||||
entry->name = new_name;
|
||||
entry->payload = userdata;
|
||||
entry->next = NULL;
|
||||
entry->valid = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user