From: Eric Biggers Date: Tue, 26 Mar 2013 17:32:08 +0000 (-0500) Subject: Avoid implementation-defined calloc of 0 bytes X-Git-Tag: v1.3.2~11 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=590fbf5626965d44f924be5cc8b04eb489f69f25 Avoid implementation-defined calloc of 0 bytes --- 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;