summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-01-18 05:39:17 +0100
committerIvan Maidanski <ivmai@mail.ru>2012-01-18 10:22:24 +0100
commit9c145e4be9548b9fabea2b4ce3ef7690ca3adda4 (patch)
treef2389c264a1367281e092d9e36df0726b680743f /tests
parentedf86f79e47aeb62bd22beed7fd79e5e4e2a543e (diff)
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).
Diffstat (limited to 'tests')
-rw-r--r--tests/realloc_test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/realloc_test.c b/tests/realloc_test.c
index 370ba46..1c1668f 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);
}