From 65a1bac8d5944c0584e56c9915bdbbd5e037cb1e Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Wed, 20 Jun 2018 00:53:37 +0200 Subject: [PATCH] Don't try to malloc() zero bytes Some platforms refuse to allocate zero bytes. This causes the entire test suite to fail miserably. To avoid this, we now fake success, and return the NULL pointer. It won't be dereferenced anyway. --- tests/test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test.c b/tests/test.c index 33e7b92..cc76c9b 100644 --- a/tests/test.c +++ b/tests/test.c @@ -20,6 +20,12 @@ static void* alloc(size_t size) { + if (size == 0) { + // Some systems refuse to allocate zero bytes. + // So we don't. Instead, we just return a non-sensical pointer. + // It shouldn't be dereferenced anyway. + return NULL; + } void *buf = malloc(size); if (buf == NULL) { fprintf(stderr, "Allocation failed: 0x%zx bytes\n", size); -- 2.47.3