]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Fix memleak in dup_stmt_json()
authorPhil Sutter <phil@nwl.cc>
Fri, 12 Oct 2018 15:50:15 +0000 (17:50 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 Oct 2018 11:37:51 +0000 (13:37 +0200)
The variable 'root' is always assigned to after initialization, so there
is no point in initializing it upon declaration.

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 f5d97c623fb3a529ebc284b2934c861ea6fbb72c..1ab2d431d0a2d877ab64fa805350cb304b6d6585 100644 (file)
@@ -1131,7 +1131,7 @@ json_t *notrack_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
 
 json_t *dup_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
 {
-       json_t *root = json_object();
+       json_t *root;
 
        if (stmt->dup.to) {
                root = json_pack("{s:o}", "addr", expr_print_json(stmt->dup.to, octx));