diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-02-28 15:54:55 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-06-19 00:01:13 +0200 |
commit | cfeb80323df626276ad825910ed23e4fe21714c8 (patch) | |
tree | 3997895265551cf38dea338ad106fe776169aefa | |
parent | cdf08f27272798d63f52df017e26ac7f491fd1ce (diff) |
evaluate: release existing datatype when evaluating unary expression
commit 494a6ed120065b764f07acd05789b816625e8e13 upstream.
Use __datatype_set() to release the existing datatype before assigning
the new one, otherwise ASAN reports the following memleak:
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x7fbc8a2b89cf in __interceptor_malloc ../../../../src/libsa
#1 0x7fbc898c96c2 in xmalloc src/utils.c:31
#2 0x7fbc8971a182 in datatype_clone src/datatype.c:1406
#3 0x7fbc89737c35 in expr_evaluate_unary src/evaluate.c:1366
#4 0x7fbc89758ae9 in expr_evaluate src/evaluate.c:3057
#5 0x7fbc89726bd9 in byteorder_conversion src/evaluate.c:243
#6 0x7fbc89739ff0 in expr_evaluate_bitwise src/evaluate.c:1491
#7 0x7fbc8973b4f8 in expr_evaluate_binop src/evaluate.c:1600
#8 0x7fbc89758b01 in expr_evaluate src/evaluate.c:3059
#9 0x7fbc8975ae0e in stmt_evaluate_arg src/evaluate.c:3198
#10 0x7fbc8975c51d in stmt_evaluate_payload src/evaluate.c:330
Fixes: faa6908fad60 ("evaluate: clone unary expression datatype to deal with dynamic datatype")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/evaluate.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index 4a4ccc1f..9585991f 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1258,7 +1258,7 @@ static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr) BUG("invalid unary operation %u\n", unary->op); } - unary->dtype = dtype_clone(arg->dtype); + __datatype_set(unary, dtype_clone(arg->dtype)); unary->byteorder = byteorder; unary->len = arg->len; return 0; |