lib/util: clang: Fix 'Null pointer passed as an argument'
authorNoel Power <noel.power@suse.com>
Wed, 3 Jul 2019 11:10:44 +0000 (11:10 +0000)
committerNoel Power <npower@samba.org>
Mon, 8 Jul 2019 09:30:09 +0000 (09:30 +0000)
Fixes lib/util/iov_buf.c:50:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang]
                        memcpy(p, iov[i].iov_base, thislen);
                        ^
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/util/iov_buf.c

index 132c7a7563739955dd4b9e545f626f566efb37cb..a9224164068314af93a0a21d8f41dac66f065ae5 100644 (file)
@@ -46,7 +46,7 @@ ssize_t iov_buf(const struct iovec *iov, int iovcnt,
                }
                needed = tmp;
 
-               if (needed <= buflen && thislen > 0) {
+               if ((p != NULL) && needed <= buflen && thislen > 0) {
                        memcpy(p, iov[i].iov_base, thislen);
                        p += thislen;
                }