1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

network: fix memleak

Fixes a bug introduced by af2aea8bb64b0dc42ecbe5549216eb567681a803.

Fixes #25883 and #25891.

(cherry picked from commit 303dfa73b389e8f6dc58954e867c21724c1446f7)
This commit is contained in:
Yu Watanabe 2023-01-16 22:07:06 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 25e30725d7
commit b10b9770d5
2 changed files with 10 additions and 2 deletions

View File

@ -1230,9 +1230,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;

View 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;