The allocated payload expression is not used after returning from that
function, so it needs to be freed again.
Simple test case:
| nft add rule inet t c reject with tcp reset
Valgrind reports definitely lost 144 bytes.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
if (ret <= 0)
return ret;
- if (payload_gen_dependency(ctx, payload, &nstmt) < 0)
- return -1;
+ if (payload_gen_dependency(ctx, payload, &nstmt) < 0) {
+ ret = -1;
+ goto out;
+ }
/*
* Unlike payload deps this adds the dependency at the beginning, i.e.
* Otherwise we'd log things that won't be rejected.
*/
list_add(&nstmt->list, &ctx->rule->stmts);
- return 0;
+out:
+ xfree(payload);
+ return ret;
}
static int stmt_evaluate_reject_inet_family(struct eval_ctx *ctx,