]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lib: names: check calloc return value in db_names_alloc
authorDenis Kirjanov <kirjanov@gmail.com>
Wed, 13 Nov 2024 10:53:49 +0000 (13:53 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 17 Nov 2024 18:11:58 +0000 (10:11 -0800)
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>
lib/names.c

index cbfa971ff61b7a6fe8ae5e6ccf7b9c22ccf41aae..4ecae92b9237d7b9248bde542697422ac1e3374d 100644 (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;
 }