]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Fix memleak in timeout_policy_json()
authorPhil Sutter <phil@nwl.cc>
Thu, 18 Jul 2019 15:16:56 +0000 (17:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 18 Jul 2019 18:01:17 +0000 (20:01 +0200)
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 <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/json.c

index 96ba557a3478b272b4d9d74f98a07bfe4d031aa7..33e0ec15f2ee1fe15853bc546b2ea9e2bb579574 100644 (file)
@@ -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();
 }