]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rt_names: check for malloc() failure
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 8 Jun 2023 01:33:49 +0000 (18:33 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 8 Jun 2023 01:33:49 +0000 (18:33 -0700)
Fixes issue reported by Gcc 13 analayzer.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/rt_names.c

index b441e98f8078a7dd88f44770c92e1cfdd74ddfd9..68db74e301ff1352422c338326b5f957b058dba4 100644 (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)];