mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-23 01:46:56 +08:00
lib: names: check calloc return value in db_names_alloc
db_names_load() may crash since it touches the hash member. Fix it by checking the return value Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
929b29f011
commit
225f74761b
@ -55,6 +55,10 @@ struct db_names *db_names_alloc(void)
|
||||
|
||||
db->size = MAX_ENTRIES;
|
||||
db->hash = calloc(db->size, sizeof(struct db_entry *));
|
||||
if (!db->hash) {
|
||||
free(db);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user