Message ID | 20241113105349.29327-1-kirjanov@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [iproute] lib: names: check calloc return value in db_names_alloc | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
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; }
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> --- lib/names.c | 4 ++++ 1 file changed, 4 insertions(+)