diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-17 09:26:10 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-17 09:28:17 -0500 |
commit | fd45e522dd8b6cbfdff32eee1f272a97080387ea (patch) | |
tree | e0836df77dca05f9bb2541cef7536553b5936ec4 /src | |
parent | f4859fc74c06bf5040e96ef68ddf7102f43cc7db (diff) |
networkd: immediately transfer ownership of route->section
The code was not incorrect previously, but I think it's easier to follow the
ownership (and the code is more likely to remain correct when updated later on),
if freeing of NetworkConfigSection* is immediately made the responsibility of
route_free(), so instead of relying on route_free() not freeing ->section
if adding to the network hashmap failed, make this freeing unconditional.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-route.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 81a065dd27..ca606c3d25 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -110,6 +110,7 @@ int route_new_static(Network *network, const char *filename, unsigned section_li if (section_line > 0) { route->section = n; + n = NULL; r = hashmap_put(network->routes_by_section, n, route); if (r < 0) @@ -122,7 +123,6 @@ int route_new_static(Network *network, const char *filename, unsigned section_li *ret = route; route = NULL; - n = NULL; return 0; } @@ -137,12 +137,12 @@ void route_free(Route *route) { assert(route->network->n_static_routes > 0); route->network->n_static_routes--; - if (route->section) { + if (route->section) hashmap_remove(route->network->routes_by_section, route->section); - network_config_section_free(route->section); - } } + network_config_section_free(route->section); + if (route->link) { set_remove(route->link->routes, route); set_remove(route->link->routes_foreign, route); |