]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix calloc success check
authorBjörn Jacke <bj@sernet.de>
Tue, 9 Nov 2010 20:33:46 +0000 (21:33 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Nov 2010 21:31:31 +0000 (22:31 +0100)
On Tru64 I had issues with this: If the number of elements or the size is 0
then you may get a NULL pointer back, which is not a sign of an error.

util.c

diff --git a/util.c b/util.c
index 73c19201801c233a8721e173a1fa21ad3ab6e21c..96fe1f7b12b8dd5836992838ce04d6b4ac6c6269 100644 (file)
--- a/util.c
+++ b/util.c
@@ -555,7 +555,7 @@ x_calloc(size_t nmemb, size_t size)
 {
        void *ret;
        ret = calloc(nmemb, size);
-       if (!ret) {
+       if (!ret && nmemb && size) {
                fatal("x_calloc: Could not allocate %lu bytes", (unsigned long)size);
        }
        return ret;