interface-ip: fix memory leak on error in interface_update_prefix_assignments()
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 12 Apr 2018 20:08:18 +0000 (22:08 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 12 Apr 2018 20:09:52 +0000 (22:09 +0200)
Detected by coverity in CID 141267

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface-ip.c

index 6726a69bb0d010516a551b47f7e42da3a15f0bf4..27e9e4147af91123d1d6c32059c5dc6b0b626c89 100644 (file)
@@ -994,8 +994,10 @@ static void interface_update_prefix_assignments(struct device_prefix *prefix, bo
                        }
 
                        entry = calloc(1, sizeof(*entry));
-                       if (!entry)
+                       if (!entry) {
+                               free(c);
                                continue;
+                       }
 
                        entry->node.key = c;
                        avl_insert(&assign_later, &entry->node);