]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: fix several expression memleaks from error path
authorSebastian Walz (sivizius) <sebastian.walz@secunet.com>
Mon, 19 Aug 2024 18:11:44 +0000 (20:11 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 21 Aug 2024 21:22:47 +0000 (23:22 +0200)
Fixes: 586ad210368b ("libnftables: Implement JSON parser")
Signed-off-by: Sebastian Walz (sivizius) <sebastian.walz@secunet.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c

index fc20fe2969f717df91040624d8c8b24f0f8c9bdb..8ca44efbb52ec5710df398fdfa4d0eb94cde724b 100644 (file)
@@ -1308,6 +1308,7 @@ static struct expr *json_parse_range_expr(struct json_ctx *ctx,
        expr_high = json_parse_primary_expr(ctx, high);
        if (!expr_high) {
                json_error(ctx, "Invalid high value in range expression.");
+               expr_free(expr_low);
                return NULL;
        }
        return range_expr_alloc(int_loc, expr_low, expr_high);
@@ -1889,6 +1890,8 @@ static struct stmt *json_parse_mangle_stmt(struct json_ctx *ctx,
                return stmt;
        default:
                json_error(ctx, "Invalid mangle statement key expression type.");
+               expr_free(key);
+               expr_free(value);
                return NULL;
        }
 }
@@ -2888,6 +2891,7 @@ static struct stmt *json_parse_optstrip_stmt(struct json_ctx *ctx,
            expr->etype != EXPR_EXTHDR ||
            expr->exthdr.op != NFT_EXTHDR_OP_TCPOPT) {
                json_error(ctx, "Illegal TCP optstrip argument");
+               expr_free(expr);
                return NULL;
        }