[vlc-devel] [PATCH] memstream: vlc_memstream_vprintf: handle vsnprintf failure
Filip Roséen
filip at atch.se
Mon Feb 27 02:58:03 CET 2017
If there is an output error in the call to vsnprintf in "len = vsnprintf( ... )",
len would be negative; leading to undefined-behavior further down the road.
---
src/text/memstream.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/text/memstream.c b/src/text/memstream.c
index 5dba5f21ed..093a419cf8 100644
--- a/src/text/memstream.c
+++ b/src/text/memstream.c
@@ -164,6 +164,9 @@ int vlc_memstream_vprintf(struct vlc_memstream *ms, const char *fmt,
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
+ if (len < 0)
+ goto error;
+
ptr = realloc(ms->ptr, ms->length + len + 1);
if (ptr == NULL)
goto error;
--
2.11.1
More information about the vlc-devel
mailing list