From: Karel Zak Date: Thu, 1 Oct 2020 11:23:34 +0000 (+0200) Subject: lib/buffer: make it robust for static analyzers [coverity scan] X-Git-Tag: v2.37-rc1~447 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f831651e3abe5eef3eaf6c5148268a3358705a8d;p=thirdparty%2Futil-linux.git lib/buffer: make it robust for static analyzers [coverity scan] Signed-off-by: Karel Zak --- diff --git a/lib/buffer.c b/lib/buffer.c index d3dc243cab..258c892d52 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -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 */