From 0980d10442088cbd791f40cbb2299d5b3eaf818a Mon Sep 17 00:00:00 2001 From: Chandra Pratap Date: Wed, 18 Jun 2025 06:20:32 +0000 Subject: [PATCH] fuzz-tests: Prevent memory leak in `fuzz-initial_channel` Changelog-None: The current test can leak memory due to improper cleanup in the case of an early return. Fix it. --- tests/fuzz/fuzz-initial_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/fuzz/fuzz-initial_channel.c b/tests/fuzz/fuzz-initial_channel.c index 2fa04c26b..c4143618a 100644 --- a/tests/fuzz/fuzz-initial_channel.c +++ b/tests/fuzz/fuzz-initial_channel.c @@ -73,8 +73,10 @@ void run(const uint8_t *data, size_t size) /* TODO: determine if it makes sense to check at each step for libfuzzer * to deduce pertinent inputs */ - if (!data || !size) + if (!data || !size) { + clean_tmpctx(); return; + } for (enum side opener = 0; opener < NUM_SIDES; opener++) { channel = new_initial_channel(tmpctx, &cid, &funding,