buffer.c: check whether buf is NULL in fuse_bufvec_advance func
authorZhiqiang Liu <liuzhiqiang26@huawei.com>
Thu, 5 Nov 2020 08:33:22 +0000 (16:33 +0800)
committerNikolaus Rath <Nikolaus@rath.org>
Fri, 6 Nov 2020 19:26:03 +0000 (19:26 +0000)
In fuse_bufvec_advance func, calling fuse_bufvec_current func
may return NULL, so we should check whether buf is NULL before
using it.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Haotian Liu <lihaotian9@huawei.com>
lib/buffer.c

index 5ab9b874554465b8107677f523b24b5c31c6c3b6..ba07b2651b32e856b5cacb6e54e02f6ce3223aa8 100644 (file)
@@ -266,6 +266,9 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
 {
        const struct fuse_buf *buf = fuse_bufvec_current(bufv);
 
+       if (!buf)
+               return 1;
+
        bufv->off += len;
        assert(bufv->off <= buf->size);
        if (bufv->off == buf->size) {