diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-12-29 18:11:32 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-12-29 18:11:36 +0100 |
commit | fdce9324c7132a9a6d3b2fe9f8449dcfc8309114 (patch) | |
tree | 728a320363144039ac885024fca1b3adb58ccd7f /src | |
parent | network: constify several arguments (diff) | |
download | systemd-fdce9324c7132a9a6d3b2fe9f8449dcfc8309114.tar.xz systemd-fdce9324c7132a9a6d3b2fe9f8449dcfc8309114.zip |
network: fix possible memory leak
When set_put() returns 0, then already stored rule will be unref()ed
from Manager.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-routing-policy-rule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index bb1c77ad26..723a44cb6d 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -343,8 +343,6 @@ static int routing_policy_rule_add_internal(Manager *m, Set **rules, const Routi if (r < 0) return r; - rule->manager = m; - r = routing_policy_rule_copy(rule, in); if (r < 0) return r; @@ -357,6 +355,8 @@ static int routing_policy_rule_add_internal(Manager *m, Set **rules, const Routi if (r == 0) return -EEXIST; + rule->manager = m; + if (ret) *ret = rule; |