]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix malloc success check
authorBjörn Jacke <bj@sernet.de>
Tue, 9 Nov 2010 20:30:16 +0000 (21:30 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 9 Nov 2010 21:31:24 +0000 (22:31 +0100)
On AIX and Tru64 I had issues with this: If you allocate 0 byte 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 ae1600698b44f9b149315ea55fb1259a24e36d26..73c19201801c233a8721e173a1fa21ad3ab6e21c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -543,7 +543,7 @@ x_malloc(size_t size)
 {
        void *ret;
        ret = malloc(size);
-       if (!ret) {
+       if (!ret && size) {
                fatal("x_malloc: Could not allocate %lu bytes", (unsigned long)size);
        }
        return ret;