netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] json: Fix memleak in timeout_policy_json()
@ 2019-07-18 15:16 Phil Sutter
  2019-07-18 18:01 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2019-07-18 15:16 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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>
---
 src/json.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/json.c b/src/json.c
index 96ba557a3478b..33e0ec15f2ee1 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();
 }
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nft PATCH] json: Fix memleak in timeout_policy_json()
  2019-07-18 15:16 [nft PATCH] json: Fix memleak in timeout_policy_json() Phil Sutter
@ 2019-07-18 18:01 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-07-18 18:01 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

On Thu, Jul 18, 2019 at 05:16:56PM +0200, Phil Sutter wrote:
> Use the correct function when populating policy property value,
> otherwise the temporary objects' refcounts are incremented.

Applied, thanks Phil.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-18 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18 15:16 [nft PATCH] json: Fix memleak in timeout_policy_json() Phil Sutter
2019-07-18 18:01 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).