From: Phil Sutter Date: Thu, 18 Jul 2019 15:16:56 +0000 (+0200) Subject: json: Fix memleak in timeout_policy_json() X-Git-Tag: v0.9.2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f8abc60c260b89a4350848e2e971ce60e642a12;p=thirdparty%2Fnftables.git json: Fix memleak in timeout_policy_json() Use the correct function when populating policy property value, otherwise the temporary objects' refcounts are incremented. Fixes: c82a26ebf7e9f ("json: Add ct timeout support") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/json.c b/src/json.c index 96ba557a3..33e0ec15f 100644 --- a/src/json.c +++ b/src/json.c @@ -266,8 +266,8 @@ static json_t *timeout_policy_json(uint8_t l4, const uint32_t *timeout) if (!root) root = json_object(); - json_object_set(root, timeout_protocol[l4].state_to_name[i], - json_integer(timeout[i])); + json_object_set_new(root, timeout_protocol[l4].state_to_name[i], + json_integer(timeout[i])); } return root ? : json_null(); }