* [nft PATCH] json: Fix memleak in set_dtype_json()
@ 2020-10-08 17:10 Phil Sutter
2020-10-12 13:03 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2020-10-08 17:10 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
Turns out json_string() already dups the input, so the temporary dup
passed to it is lost.
Fixes: e70354f53e9f6 ("libnftables: Implement JSON output support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/json.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/json.c b/src/json.c
index 121dfb247d967..a8824d3fc05a9 100644
--- a/src/json.c
+++ b/src/json.c
@@ -62,7 +62,7 @@ static json_t *set_dtype_json(const struct expr *key)
tok = strtok(namedup, " .");
while (tok) {
- json_t *jtok = json_string(xstrdup(tok));
+ json_t *jtok = json_string(tok);
if (!root)
root = jtok;
else if (json_is_string(root))
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [nft PATCH] json: Fix memleak in set_dtype_json()
2020-10-08 17:10 [nft PATCH] json: Fix memleak in set_dtype_json() Phil Sutter
@ 2020-10-12 13:03 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-10-12 13:03 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Thu, Oct 08, 2020 at 07:10:13PM +0200, Phil Sutter wrote:
> Turns out json_string() already dups the input, so the temporary dup
> passed to it is lost.
LGTM.
> Fixes: e70354f53e9f6 ("libnftables: Implement JSON output support")
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> src/json.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/json.c b/src/json.c
> index 121dfb247d967..a8824d3fc05a9 100644
> --- a/src/json.c
> +++ b/src/json.c
> @@ -62,7 +62,7 @@ static json_t *set_dtype_json(const struct expr *key)
>
> tok = strtok(namedup, " .");
> while (tok) {
> - json_t *jtok = json_string(xstrdup(tok));
> + json_t *jtok = json_string(tok);
> if (!root)
> root = jtok;
> else if (json_is_string(root))
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-12 13:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 17:10 [nft PATCH] json: Fix memleak in set_dtype_json() Phil Sutter
2020-10-12 13:03 ` 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).