From: Hugh McMaster Subject: [PATCH] libs/wine/string.c: Always return (int)written Message-Id: Date: Wed, 17 Dec 2014 22:47:05 +1100 Both GCC and Windows versions of vsnprintf return the number of chars that would be written to a given buffer when vsnprintf(NULL, 0, fmt, va_args) is called. Wine currently returns -1, which is incorrect. Also, if there is a short buffer, that is, buffer <= len, not only is any output truncated, but the return value is the number of chars that would be written if the buffer had sufficient space. Here, Wine returns -1, which is, again, incorrect. In all cases, the return value should be the number of chars written or the number of chars that would be written if the buffer has sufficient space. From 61ead94f8c9cfd124864bf7f1c6612f02b4b76ae Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Wed, 17 Dec 2014 21:04:23 +1100 Subject: [PATCH] libs/wine/string.c: Always return (int)written --- libs/wine/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wine/string.c b/libs/wine/string.c index 45a8810..362891e 100644 --- a/libs/wine/string.c +++ b/libs/wine/string.c @@ -502,7 +502,7 @@ int vsnprintfW(WCHAR *str, size_t len, const WCHAR *format, va_list valist) } /* FIXME: POSIX [v]snprintf() returns the equivalent of written, not -1, on short buffer. */ - return written < len ? (int)written : -1; + return (int)written; } int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist ) -- 1.9.1