From: Denis Kirjanov Date: Wed, 13 Nov 2024 10:53:49 +0000 (+0300) Subject: lib: names: check calloc return value in db_names_alloc X-Git-Tag: v6.12.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=225f74761b091e51444cf1f9686547f3c42e44b3;p=thirdparty%2Fiproute2.git 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 Signed-off-by: Stephen Hemminger --- diff --git a/lib/names.c b/lib/names.c index cbfa971f..4ecae92b 100644 --- a/lib/names.c +++ b/lib/names.c @@ -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; }