From 9c145e4be9548b9fabea2b4ce3ef7690ca3adda4 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 18 Jan 2012 08:39:17 +0400 Subject: [PATCH] Fix realloc_test to check GC_malloc result for NULL * tests/realloc_test.c (main): Prevent NULL pointer dereference (exit with an error message in case of NULL returned by GC_malloc). --- tests/realloc_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/realloc_test.c b/tests/realloc_test.c index 370ba466..1c1668f2 100644 --- a/tests/realloc_test.c +++ b/tests/realloc_test.c @@ -15,8 +15,8 @@ int main(void) { int **p = GC_MALLOC(sizeof(int *)); int *q = GC_MALLOC_ATOMIC(sizeof(int)); - if (*p != 0) { - fprintf(stderr, "GC_malloc returned garbage\n"); + if (p == 0 || *p != 0) { + fprintf(stderr, "GC_malloc returned garbage (or NULL)\n"); exit(1); } -- 2.49.0