From: Dale Weiler Date: Thu, 29 May 2014 01:51:29 +0000 (-0400) Subject: Handle encoding errors for platform_vasprintf X-Git-Tag: xonotic-v0.8.1~9^2~30 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c33755b0077bc74742c67a03aa2a0a11f10085da;p=xonotic%2Fgmqcc.git Handle encoding errors for platform_vasprintf --- diff --git a/ansi.c b/ansi.c index 029508a..e377424 100644 --- a/ansi.c +++ b/ansi.c @@ -62,6 +62,9 @@ int platform_vasprintf(char **dat, const char *fmt, va_list args) { len = vsnprintf(buf, sizeof(buf), fmt, cpy); va_end (cpy); + if (len < 0) + return len; + if (len < (int)sizeof(buf)) { *dat = util_strdup(buf); return len;