rt_names: check for malloc() failure

Fixes issue reported by Gcc 13 analayzer.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Stephen Hemminger 2023-06-07 18:33:49 -07:00
parent 5c4697a405
commit 507fe04218

View File

@ -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)];