From: Rusty Russell Date: Wed, 31 Oct 2012 11:04:20 +0000 (+1030) Subject: crcsync: fix memory leak in tests. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=bd9ff08715f762bbf60e559ff788b25aeec33fff;hp=b94efb332225f6dbbe7ff36b8bee4a18e892fe23 crcsync: fix memory leak in tests. /home/rusty/devel/cvs/ccan/ccan/crcsync/test/run-crash.c:==6923== 112 bytes in 1 blocks are definitely lost in loss record 2 of 3 ==6923== at 0x402BA7A: malloc (vg_replace_malloc.c:261) ==6923== by 0x80492EE: crcblocks (run-crash.c:20) ==6923== by 0x8049448: main (run-crash.c:62) ==6923== 2,217 (2,212 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3 ==6923== at 0x402BA7A: malloc (vg_replace_malloc.c:261) ==6923== by 0x8048AA0: crc_context_new (crcsync.c:85) ==6923== by 0x8049476: main (run-crash.c:64) /home/rusty/devel/cvs/ccan/ccan/crcsync/test/run.c:==11793== 512 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==11793== at 0x402A52B: calloc (vg_replace_malloc.c:462) ==11793== by 0x8049A3F: main (run.c:128) ==11793== 512 bytes in 1 blocks are definitely lost in loss record 2 of 2 ==11793== at 0x402A52B: calloc (vg_replace_malloc.c:462) ==11793== by 0x8049A57: main (run.c:129) Signed-off-by: Rusty Russell --- diff --git a/ccan/crcsync/test/run-crash.c b/ccan/crcsync/test/run-crash.c index 2be3b36d..3bf49f64 100644 --- a/ccan/crcsync/test/run-crash.c +++ b/ccan/crcsync/test/run-crash.c @@ -92,6 +92,7 @@ int main(int argc, char *argv[]) } } ok1(expected_i == ARRAY_SIZE(expected)); - + crc_context_free(crcctx); + free(crc_info1.crcs); return 0; } diff --git a/ccan/crcsync/test/run.c b/ccan/crcsync/test/run.c index 2c48b378..f51ac23f 100644 --- a/ccan/crcsync/test/run.c +++ b/ccan/crcsync/test/run.c @@ -285,5 +285,7 @@ int main(int argc, char *argv[]) BLOCK_SIZE, res, num_res); } + free(buffer1); + free(buffer2); return exit_status(); }