summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-01-08 00:32:29 +0200
committerLasse Collin <lasse.collin@tukaani.org>2023-01-08 00:32:29 +0200
commit0e1545fea39c0514c7b7032a0a3592a9a33d2848 (patch)
tree2babb43e69ef43598c366f1b0a19fd5c61655804 /tests
parent69d5d78c6904668eb09a131da86276beec3281f8 (diff)
downloadxz-0e1545fea39c0514c7b7032a0a3592a9a33d2848.tar.gz
Tests: tuktest.h: Support tuktest_malloc(0).
It's not needed in XZ Utils at least for now. It's good to support it still because if such use is needed later, it wouldn't be caught on GNU/Linux since malloc(0) from glibc returns non-NULL.
Diffstat (limited to 'tests')
-rw-r--r--tests/tuktest.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/tuktest.h b/tests/tuktest.h
index 1891818..508eace 100644
--- a/tests/tuktest.h
+++ b/tests/tuktest.h
@@ -2,7 +2,7 @@
//
/// \file tuktest.h
/// \brief Helper macros for writing simple test programs
-/// \version 2022-06-16
+/// \version 2023-01-08
///
/// Some inspiration was taken from STest by Keith Nicholas.
///
@@ -349,7 +349,7 @@ static struct tuktest_malloc_record *tuktest_malloc_global = NULL;
static void *
tuktest_malloc_impl(size_t size, const char *filename, unsigned line)
{
- void *p = malloc(size);
+ void *p = malloc(size == 0 ? 1 : size);
struct tuktest_malloc_record *r = malloc(sizeof(*r));
if (p == NULL || r == NULL) {