From: Yu Watanabe Date: Fri, 2 Nov 2018 08:14:05 +0000 (+0900) Subject: network: fix memleak in static prefix X-Git-Tag: v240~414^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ecee0abe775dd02ebd8ca3211ce84707a81fa8b8;p=thirdparty%2Fsystemd.git network: fix memleak in static prefix The fix by 744faf5e4e64e26181f03d1d9fa292ce6fb1456a is not perfect, as the section leaks if `hashmap_put()` in `prefix_new_static()` fails. --- diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index dc8b24a238a..600fb27d755 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -98,13 +98,12 @@ void prefix_free(Prefix *prefix) { assert(prefix->network->n_static_prefixes > 0); prefix->network->n_static_prefixes--; - if (prefix->section) { + if (prefix->section) hashmap_remove(prefix->network->prefixes_by_section, prefix->section); - network_config_section_free(prefix->section); - } } + network_config_section_free(prefix->section); prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix); free(prefix);