jail: actually check calloc return value
authorDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 23:39:12 +0000 (00:39 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 23:46:54 +0000 (00:46 +0100)
Instead of checking the return value of calloc(), the check intended
for that would rather check if the pointer passed as an argument.
As that doesn't make much sense, rather actually check calloc()
return value.

Coverity CID: 1490071 Dereference before null check
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/fs.c

index d6aed0048d7001ff0473c1dfca6894a0f5532171..210567e79eab2f99863f93c2d38c567e92df255e 100644 (file)
--- a/jail/fs.c
+++ b/jail/fs.c
@@ -357,7 +357,7 @@ static int parseOCImountopts(struct blob_attr *msg, unsigned long *mount_flags,
 
        if (len) {
                *mount_data = calloc(len + 1, sizeof(char));
-               if (!mount_data)
+               if (!(*mount_data))
                        return ENOMEM;
 
                len = 0;