summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-10-24 11:57:08 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2023-11-09 12:35:01 +0100
commitd3b5b4b88c4d34bb0325fde0a6bf0a918ebfe55a (patch)
tree1818cab6a24537572cca3b5eac722a444a7d70cb /src/evaluate.c
parent1f867d0d07122f54f76e20af3c636ce66102b683 (diff)
gmputil: add nft_gmp_free() to free strings from mpz_get_str()
mpz_get_str() (with NULL as first argument) will allocate a buffer using the allocator functions (mp_set_memory_functions()). We should free those buffers with the corresponding free function. Add nft_gmp_free() for that and use it. The name nft_gmp_free() is chosen because "mini-gmp.c" already has an internal define called gmp_free(). There wouldn't be a direct conflict, but using the same name is confusing. And maybe our own defines should have a clear nft prefix. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index 788cac1f..ba6aa300 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -400,7 +400,7 @@ static int expr_evaluate_integer(struct eval_ctx *ctx, struct expr **exprp)
expr_error(ctx->msgs, expr,
"Value %s exceeds valid range 0-%u",
valstr, ctx->ectx.maxval);
- free(valstr);
+ nft_gmp_free(valstr);
return -1;
}
@@ -416,8 +416,8 @@ static int expr_evaluate_integer(struct eval_ctx *ctx, struct expr **exprp)
expr_error(ctx->msgs, expr,
"Value %s exceeds valid range 0-%s",
valstr, rangestr);
- free(valstr);
- free(rangestr);
+ nft_gmp_free(valstr);
+ nft_gmp_free(rangestr);
mpz_clear(mask);
return -1;
}