diff mbox series

[nft] libnftables: set variable array to NULL after release

Message ID 20240903121910.305004-1-pablo@netfilter.org
State Superseded
Headers show
Series [nft] libnftables: set variable array to NULL after release | expand

Commit Message

Pablo Neira Ayuso Sept. 3, 2024, 12:19 p.m. UTC
User reports that:

1. Call nft_ctx_clear_vars();
2. Call nft_ctx_free().

because nft_ctx_clear_vars() is called from nft_ctx_free().

results in double free, set ctx->vars to NULL from nft_ctx_clear_vars().

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1772
Fixes: 4e8dff2cb4da ("src: expose nft_ctx_clear_vars as API")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/libnftables.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/src/libnftables.c b/src/libnftables.c
index 7fc81515258d..2ae215013cb0 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -160,6 +160,7 @@  void nft_ctx_clear_vars(struct nft_ctx *ctx)
 	}
 	ctx->num_vars = 0;
 	free(ctx->vars);
+	ctx->vars = NULL;
 }
 
 EXPORT_SYMBOL(nft_ctx_add_include_path);