malloc wrappers in test cases: fix handling of failed realloc()
diff --git a/tests/common/malloc_wrappers.c b/tests/common/malloc_wrappers.c
index ad8cbdc..fd12608 100644
--- a/tests/common/malloc_wrappers.c
+++ b/tests/common/malloc_wrappers.c
@@ -82,6 +82,12 @@
assert(alloc_count > 0);
buf = realloc(buf, size + GUARD_SIZE);
+ if (!buf)
+ {
+ if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to %u failed\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)size);
+ return NULL;
+ }
+
((size_t*)buf)[0] = size;
((size_t*)buf)[1] = CHECK1;
((size_t*)(buf + size))[2] = CHECK2;