From: Phil Sutter Date: Thu, 8 Oct 2020 17:10:13 +0000 (+0200) Subject: json: Fix memleak in set_dtype_json() X-Git-Tag: v0.9.7~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=88af46df5544d9a0b080f23fb2902c86659f0c86;p=thirdparty%2Fnftables.git json: Fix memleak in set_dtype_json() 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 Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/json.c b/src/json.c index 121dfb24..a8824d3f 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))