fix a memleak in host route dependency handling
[project/netifd.git] / interface-ip.c
index e09a74f..3957b48 100644 (file)
@@ -160,8 +160,10 @@ interface_ip_add_target_route(union if_addr *addr, bool v6)
                interface_ip_find_route_target(iface, addr, v6, &r_next);
        }
 
-       if (!r_next)
+       if (!r_next) {
+               free(route);
                return NULL;
+       }
 
        iface = r_next->iface;
        memcpy(&route->nexthop, &r_next->nexthop, sizeof(route->nexthop));
@@ -301,7 +303,7 @@ interface_update_proto_addr(struct vlist_tree *tree,
                        uint32_t *a = (uint32_t *) &a_new->addr;
 
                        mask >>= a_new->mask;
-                       a_new->broadcast = *a | mask;
+                       a_new->broadcast = *a | htonl(mask);
                }
        }