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@xxxxxxxxxxxxx> --- src/evaluate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evaluate.c b/src/evaluate.c index 25c07d90695b..f79667bd41ea 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1359,7 +1359,7 @@ static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr) BUG("invalid unary operation %u\n", unary->op); } - unary->dtype = datatype_clone(arg->dtype); + __datatype_set(unary, datatype_clone(arg->dtype)); unary->byteorder = byteorder; unary->len = arg->len; return 0; -- 2.30.2