From: cuz Date: Thu, 1 Jun 2000 16:41:28 +0000 (+0000) Subject: Abort on string overflow X-Git-Tag: V2.12.0~3491 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58a9481d8d5917d0bf6149fd92b588f37e31c2ab;p=cc65 Abort on string overflow git-svn-id: svn://svn.cc65.org/cc65/trunk@21 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/common/xsprintf.c b/src/common/xsprintf.c index e95eef4ca..600e12823 100644 --- a/src/common/xsprintf.c +++ b/src/common/xsprintf.c @@ -65,14 +65,14 @@ int xvsprintf (char* Buf, size_t BufSize, const char* Format, va_list ap) /* Replacement function for sprintf */ { #if defined(__WATCOMC__) - return _vbprintf (Buf, BufSize, Format, ap); + int Res = _vbprintf (Buf, BufSize, Format, ap); #elsif defined(__GNUC__) - return vsnprintf (Buf, BufSize, Format, ap); + int Res = vsnprintf (Buf, BufSize, Format, ap); #else int Res = vsprintf (Buf, Format, ap); - assert ((unsigned) Res < BufSize); - return Res; #endif + assert (Res >= 0 && (unsigned) Res < BufSize); + return Res; }