From a7acaaf6ab0ef91ffea03484141f037d2b2e7355 Mon Sep 17 00:00:00 2001 From: Shivshankar-Reddy Date: Fri, 24 May 2024 18:01:24 +0000 Subject: [PATCH] Update free before return Signed-off-by: Shivshankar-Reddy --- src/unit/test_crc64combine.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/unit/test_crc64combine.c b/src/unit/test_crc64combine.c index cb1d96f1eb..2de3e74c22 100644 --- a/src/unit/test_crc64combine.c +++ b/src/unit/test_crc64combine.c @@ -138,19 +138,35 @@ int test_crc64combine(int argc, char **argv, int flags) { /* get the single-character version for single-byte Redis behavior */ set_crc64_cutoffs(0, crc64_test_size+1); - if (bench_crc64(data, crc64_test_size, passes, expect, "crc_1byte", csv)) return 1; + if (bench_crc64(data, crc64_test_size, passes, expect, "crc_1byte", csv)) { + zfree(data); + data = NULL; + return 1; + } set_crc64_cutoffs(crc64_test_size+1, crc64_test_size+1); /* run with 8-byte "single" path, crcfaster */ - if (bench_crc64(data, crc64_test_size, passes, expect, "crcspeed", csv)) return 1; + if (bench_crc64(data, crc64_test_size, passes, expect, "crcspeed", csv)) { + zfree(data); + data = NULL; + return 1; + } /* run with dual 8-byte paths */ set_crc64_cutoffs(1, crc64_test_size+1); - if (bench_crc64(data, crc64_test_size, passes, expect, "crcdual", csv)) return 1; + if (bench_crc64(data, crc64_test_size, passes, expect, "crcdual", csv)) { + zfree(data); + data = NULL; + return 1; + } /* run with tri 8-byte paths */ set_crc64_cutoffs(1, 1); - if (bench_crc64(data, crc64_test_size, passes, expect, "crctri", csv)) return 1; + if (bench_crc64(data, crc64_test_size, passes, expect, "crctri", csv)) { + zfree(data); + data = NULL; + return 1; + } /* Be free memory region, be free. */ zfree(data);