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:
Denis Kirjanov 2024-11-13 13:53:49 +03:00 committed by Stephen Hemminger
parent 929b29f011
commit 225f74761b

View File

@ -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;
}