From 03ac71b8c99312aa76f9f38cc9ce1bd1287c9d57 Mon Sep 17 00:00:00 2001 From: jsalling Date: Sun, 21 Aug 2016 11:27:47 -0500 Subject: [PATCH] Reorder free calls to free all memory The internal malloc must free in LIFO order --- extras/fixture/test/unity_fixture_Test.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/extras/fixture/test/unity_fixture_Test.c b/extras/fixture/test/unity_fixture_Test.c index 0729e1f..42c3aab 100644 --- a/extras/fixture/test/unity_fixture_Test.c +++ b/extras/fixture/test/unity_fixture_Test.c @@ -523,14 +523,11 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem) void* n1 = malloc(10); void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1); void* n2 = malloc(10); - TEST_ASSERT_NOT_NULL(m); - if (out_of_mem == NULL) - { - free(n1); - TEST_ASSERT_NULL(out_of_mem); - } - TEST_ASSERT_NOT_EQUAL(n2, n1); free(n2); + if (out_of_mem == NULL) free(n1); free(m); + TEST_ASSERT_NOT_NULL(m); + TEST_ASSERT_NULL(out_of_mem); + TEST_ASSERT_NOT_EQUAL(n2, n1); #endif } -- GitLab