From 590fbf5626965d44f924be5cc8b04eb489f69f25 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 26 Mar 2013 12:32:08 -0500 Subject: [PATCH] Avoid implementation-defined calloc of 0 bytes --- programs/imagex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/programs/imagex.c b/programs/imagex.c index c3ab4b73..dd1a1243 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -551,7 +551,9 @@ parse_source_list(tchar **source_list_contents_p, size_t source_list_nchars, nlines++; } - sources = calloc(nlines, sizeof(*sources)); + /* Always allocate at least 1 slot, just in case the implementation of + * calloc() returns NULL if 0 bytes are requested. */ + sources = calloc(nlines ?: 1, sizeof(*sources)); if (!sources) goto oom; p = source_list_contents; -- 2.43.0