From 2eaea5dae5b6427b9e034e067ccacfc0b76aa9d0 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sat, 27 Mar 2021 18:21:17 -0400 Subject: test_verify_sbat_null_sbat_section(): call cleanup_sbat_var() This fixes a memory leak caused by test_verify_sbat_null_sbat_section() not calling cleanup_sbat_var(). Before: ==2591367== Memcheck, a memory error detector ==2591367== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==2591367== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info ==2591367== Command: ./test-sbat ==2591367== ==2591367== ==2591367== HEAP SUMMARY: ==2591367== in use at exit: 56 bytes in 1 blocks ==2591367== total heap usage: 17 allocs, 16 frees, 5,382 bytes allocated ==2591367== ==2591367== 56 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==2591367== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==2591367== by 0x402AEB: parse_sbat_var_data (sbat.c:234) ==2591367== by 0x40189D: UnknownInlinedFun (test-sbat.c:445) ==2591367== by 0x40189D: main (test-sbat.c:1033) ==2591367== ==2591367== LEAK SUMMARY: ==2591367== definitely lost: 56 bytes in 1 blocks ==2591367== indirectly lost: 0 bytes in 0 blocks ==2591367== possibly lost: 0 bytes in 0 blocks ==2591367== still reachable: 0 bytes in 0 blocks ==2591367== suppressed: 0 bytes in 0 blocks ==2591367== ==2591367== For lists of detected and suppressed errors, rerun with: -s ==2591367== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) After: ==2645037== Memcheck, a memory error detector ==2645037== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==2645037== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info ==2645037== Command: ./test-sbat ==2645037== ==2645037== ==2645037== HEAP SUMMARY: ==2645037== in use at exit: 0 bytes in 0 blocks ==2645037== total heap usage: 17 allocs, 17 frees, 5,382 bytes allocated ==2645037== ==2645037== All heap blocks were freed -- no leaks are possible ==2645037== ==2645037== For lists of detected and suppressed errors, rerun with: -s ==2645037== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Signed-off-by: Peter Jones --- test-sbat.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test-sbat.c') diff --git a/test-sbat.c b/test-sbat.c index e97c3d87..b64aa1e9 100644 --- a/test-sbat.c +++ b/test-sbat.c @@ -440,14 +440,19 @@ test_verify_sbat_null_sbat_section(void) list_t test_sbat_var; size_t n = 0; struct sbat_section_entry **entries = NULL; + int rc = -1; INIT_LIST_HEAD(&test_sbat_var); status = parse_sbat_var_data(&test_sbat_var, sbat_var_data, sizeof(sbat_var_data)); - assert_equal_return(status, EFI_SUCCESS, -1, "got %#x expected %#x\n"); + assert_equal_goto(status, EFI_SUCCESS, err, "got %#x expected %#x\n"); - status = verify_sbat_helper(&sbat_var, n, entries); - assert_equal_return(status, EFI_SUCCESS, -1, "got %#x expected %#x\n"); - return 0; + status = verify_sbat_helper(&test_sbat_var, n, entries); + assert_equal_goto(status, EFI_SUCCESS, err, "got %#x expected %#x\n"); + rc = 0; +err: + cleanup_sbat_var(&test_sbat_var); + + return rc; } #if 0 -- cgit v1.2.3