From: Stephen Hemminger Date: Thu, 8 Jun 2023 01:33:49 +0000 (-0700) Subject: rt_names: check for malloc() failure X-Git-Tag: v6.4.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=507fe042181c8e481e4463ab66b3f7af897a5500;p=thirdparty%2Fiproute2.git rt_names: check for malloc() failure Fixes issue reported by Gcc 13 analayzer. Signed-off-by: Stephen Hemminger --- diff --git a/lib/rt_names.c b/lib/rt_names.c index b441e98f8..68db74e30 100644 --- a/lib/rt_names.c +++ b/lib/rt_names.c @@ -81,6 +81,10 @@ rtnl_hash_initialize(const char *file, struct rtnl_hash_entry **hash, int size) continue; entry = malloc(sizeof(*entry)); + if (entry == NULL) { + fprintf(stderr, "malloc error: for entry\n"); + break; + } entry->id = id; entry->name = strdup(namebuf); entry->next = hash[id & (size - 1)];