1
0
mirror of https://github.com/ThrowTheSwitch/Unity synced 2025-05-20 02:09:32 -04:00

Update unity_fixture_Test.c

I believe if realloc() returns a pointer to a different location, the old location is freed. However, the pointer 'n1' is not freed if realloc fails to obtain a large enough block of memory and returns NULL. (more details on [StackOverflow](http://stackoverflow.com/a/16676964)).
This commit is contained in:
Bryon Gloden, CISSP® 2016-07-28 17:11:11 -04:00 committed by GitHub
parent 094c05e904
commit 13160e5f1e

@ -524,7 +524,11 @@ TEST(InternalMalloc, ReallocFailDoesNotFreeMem)
void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1);
void* n2 = malloc(10);
TEST_ASSERT_NOT_NULL(m);
TEST_ASSERT_NULL(out_of_mem);
if (out_of_mem == NULL)
{
free(n1);
TEST_ASSERT_NULL(out_of_mem);
}
TEST_ASSERT_NOT_EQUAL(n2, n1);
free(n2);
free(m);