]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix memleak in static prefix
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Nov 2018 08:14:05 +0000 (17:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 3 Nov 2018 15:31:46 +0000 (00:31 +0900)
The fix by 744faf5e4e64e26181f03d1d9fa292ce6fb1456a is not perfect,
as the section leaks if `hashmap_put()` in `prefix_new_static()` fails.

src/network/networkd-radv.c

index dc8b24a238aabca31d976452bbef10f83f609b7b..600fb27d75586ae9d2737449ecdd27cccbb0b32d 100644 (file)
@@ -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);