]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix memleak
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 16 Jan 2023 13:07:06 +0000 (22:07 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 16 Jan 2023 19:42:59 +0000 (19:42 +0000)
Fixes a bug introduced by af2aea8bb64b0dc42ecbe5549216eb567681a803.

Fixes #25883 and #25891.

src/network/networkd-address.c
src/network/networkd-route.c

index 5b3b7d128aaef8f0e556a4d59418d7f46ef92ca5..c691a5e0575c05d261196697e09fbe85cd00ed6c 100644 (file)
@@ -1216,9 +1216,13 @@ int link_request_address(
 
         (void) address_get(link, address, &existing);
 
-        if (address->lifetime_valid_usec == 0)
+        if (address->lifetime_valid_usec == 0) {
+                if (consume_object)
+                        address_free(address);
+
                 /* The requested address is outdated. Let's remove it. */
                 return address_remove_and_drop(existing);
+        }
 
         if (!existing) {
                 _cleanup_(address_freep) Address *tmp = NULL;
index d1f3bab0922e05b181d314e6d5cefa16c61297f0..5214a8ad2c91cd789723059add21846fad6eceeb 100644 (file)
@@ -1437,9 +1437,13 @@ int link_request_route(
 
         (void) route_get(link->manager, link, route, &existing);
 
-        if (route->lifetime_usec == 0)
+        if (route->lifetime_usec == 0) {
+                if (consume_object)
+                        route_free(route);
+
                 /* The requested route is outdated. Let's remove it. */
                 return route_remove_and_drop(existing);
+        }
 
         if (!existing) {
                 _cleanup_(route_freep) Route *tmp = NULL;