]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Fix memleak in set_dtype_json()
authorPhil Sutter <phil@nwl.cc>
Thu, 8 Oct 2020 17:10:13 +0000 (19:10 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 22 Oct 2020 17:12:11 +0000 (19:12 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/json.c

index 121dfb247d96732a6d304f4b33870dccba7099da..a8824d3fc05a9613e94e19e69d69f6cbcbe94a13 100644 (file)
@@ -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))