Skip to contentSkip to conversation

json: Fix memleak in timeout_policy_json()

PATCH Applied Phil Sutter 2 participants 2 messages Jul 18, 2019 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 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")
---
 src/json.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/json.c +2 -2
index 96ba557a3478b..33e0ec15f2ee1 100644
@@ -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();
 }
Signature · 1 line
2.22.0
maintainer Applied
#1 lore raw
Quoted 2 lines · Phil Sutter

Use the correct function when populating policy property value, otherwise the temporary objects' refcounts are incremented.

Applied, thanks Phil.