]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/buffer: make it robust for static analyzers [coverity scan]
authorKarel Zak <kzak@redhat.com>
Thu, 1 Oct 2020 11:23:34 +0000 (13:23 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Oct 2020 11:23:34 +0000 (13:23 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/buffer.c

index d3dc243cab6e020947f52531a0e437de02365f71..258c892d525eece0b23eadad00d915928f13f71e 100644 (file)
@@ -81,6 +81,9 @@ int ul_buffer_append_data(struct ul_buffer *buf, const char *data, size_t sz)
                if (rc)
                        return rc;
        }
+       if (!buf->end)
+               return -EINVAL; /* make static analyzers happy */
+
        memcpy(buf->end, data, sz);
        buf->end += sz;
        *buf->end = '\0';       /* make sure it's terminated */