From: fredb Date: Tue, 10 Jan 2006 20:25:46 +0000 (+0000) Subject: MSVC vsnprintf ( in fact _vsnprinft ) returns -1 when the buffer is too short X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=36e7684d9a8dadd8c9a9c19d973034499ed3eafd;p=simgear.git MSVC vsnprintf ( in fact _vsnprinft ) returns -1 when the buffer is too short --- diff --git a/simgear/nasal/lib.c b/simgear/nasal/lib.c index 504a33c2..a9feb00c 100644 --- a/simgear/nasal/lib.c +++ b/simgear/nasal/lib.c @@ -228,13 +228,14 @@ static naRef f_die(naContext c, naRef me, int argc, naRef* args) // until it fits. Returned buffer should be freed by the caller. char* dosprintf(char* f, ...) { + int l; char* buf; va_list va; int len = 16; while(1) { buf = naAlloc(len); va_start(va, f); - if(vsnprintf(buf, len, f, va) < len) { + if((l=vsnprintf(buf, len, f, va)) < len && l!=-1) { va_end(va); return buf; }