From: Jan Kiszka <[email protected]>

ebg_env_close frees the bgenv of the passed ebgend_t. So we must no only
refrain from doing that again, we also need to reinitialize data on the
second test run.

Signed-off-by: Jan Kiszka <[email protected]>
---
 tools/tests/test_ebgenv_api.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/tests/test_ebgenv_api.c b/tools/tests/test_ebgenv_api.c
index e18c055..dea4b2c 100644
--- a/tools/tests/test_ebgenv_api.c
+++ b/tools/tests/test_ebgenv_api.c
@@ -572,7 +572,8 @@ START_TEST(ebgenv_api_ebg_env_close)
        e.bgenv = calloc(1, sizeof(BGENV));
        ck_assert(e.bgenv != NULL);

-       ((BGENV *)e.bgenv)->data = calloc(1, sizeof(BG_ENVDATA));
+       void *data = calloc(1, sizeof(BG_ENVDATA));
+       ((BGENV *)e.bgenv)->data = data;
        bgenv_write_fake.return_val = false;
        ret = ebg_env_close(&e);

@@ -580,15 +581,16 @@ START_TEST(ebgenv_api_ebg_env_close)

        /* Test if ebg_env_close is successful if all prerequisites are met
         */
+       e.bgenv = calloc(1, sizeof(BGENV));
+       ck_assert(e.bgenv != NULL);
+       ((BGENV *)e.bgenv)->data = data;
        bgenv_write_fake.return_val = true;
-       BGENV *save_ptr = e.bgenv;
        ret = ebg_env_close(&e);

        ck_assert_int_eq(ret, 0);
        ck_assert(e.bgenv == NULL);

-       free(save_ptr->data);
-       free(save_ptr);
+       free(data);
 }
 END_TEST

--
2.26.2

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/219b91f422a28ade28913b0e670dd269b3ac5183.1592139558.git.jan.kiszka%40web.de.

Reply via email to