aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Wollny <gert.wollny@collabora.com>2022-11-08 17:18:21 +0100
committerMarge Bot <emma+marge@anholt.net>2022-11-10 07:03:02 +0000
commit036b354951bdbc1a47a90959ca07511438f72ffe (patch)
tree3081e89e156111eef43765d09a2b730631bc0fe8
parent59ca6c0c75bda3b8b6a1af43e0f28fc5668142c5 (diff)
downloadvirglrenderer-036b354951bdbc1a47a90959ca07511438f72ffe.tar.gz
strbuf: clean up va_list with va_end
Fixes Coverity ID: 1527229, 1527195 "Missing varargs init or cleanup" Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/975>
-rw-r--r--src/vrend_strbuf.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vrend_strbuf.h b/src/vrend_strbuf.h
index da5cb470..8568d010 100644
--- a/src/vrend_strbuf.h
+++ b/src/vrend_strbuf.h
@@ -148,11 +148,14 @@ static inline void strbuf_vappendf(struct vrend_strbuf *sb, const char *fmt, va_
int len = vsnprintf(sb->buf + sb->size, sb->alloc_size - sb->size, fmt, ap);
if (len >= (int)(sb->alloc_size - sb->size)) {
- if (!strbuf_grow(sb, len))
- return;
+ if (!strbuf_grow(sb, len)) {
+ goto end;
+ }
vsnprintf(sb->buf + sb->size, sb->alloc_size - sb->size, fmt, cp);
}
sb->size += len;
+end:
+ va_end(ap);
}
__attribute__((format(printf, 2, 3)))
@@ -172,10 +175,12 @@ static inline void strbuf_vfmt(struct vrend_strbuf *sb, const char *fmt, va_list
int len = vsnprintf(sb->buf, sb->alloc_size, fmt, ap);
if (len >= (int)(sb->alloc_size)) {
if (!strbuf_grow(sb, len))
- return;
+ goto end;
vsnprintf(sb->buf, sb->alloc_size, fmt, cp);
}
sb->size = len;
+end:
+ va_end(ap);
}
__attribute__((format(printf, 2, 3)))