summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-09-14 16:03:25 -0400
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2012-09-15 19:46:54 -0400
commit663c21d4ac1a011f71fe48a6a8b6934cd2ef1a4b (patch)
tree341dffc8c1eccb7321371e0e52f75ea9f4415b79 /compat
parente1b449604018c4e5eedf4abf393c0a170fd407cb (diff)
downloadffmpeg-streaming-663c21d4ac1a011f71fe48a6a8b6934cd2ef1a4b.zip
ffmpeg-streaming-663c21d4ac1a011f71fe48a6a8b6934cd2ef1a4b.tar.gz
compat/vsnprintf: return number of bytes required on truncation.
This conforms to C99, but requires Windows >= XP.
Diffstat (limited to 'compat')
-rw-r--r--compat/msvcrt/snprintf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/compat/msvcrt/snprintf.c b/compat/msvcrt/snprintf.c
index 36f6dd1..6787aad 100644
--- a/compat/msvcrt/snprintf.c
+++ b/compat/msvcrt/snprintf.c
@@ -43,9 +43,10 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt,
va_list ap)
{
int ret;
+ va_list ap_copy;
if (n == 0)
- return 0;
+ return _vscprintf(fmt, ap);
else if (n > INT_MAX)
return AVERROR(EOVERFLOW);
@@ -56,9 +57,11 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt,
* _snprintf/_vsnprintf() to workaround this problem.
* See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */
memset(s, 0, n);
- ret = _vsnprintf(s, n - 1, fmt, ap);
+ va_copy(ap_copy, ap);
+ ret = _vsnprintf(s, n - 1, fmt, ap_copy);
+ va_end(ap_copy);
if (ret == -1)
- ret = n;
+ ret = _vscprintf(fmt, ap);
return ret;
}
OpenPOWER on IntegriCloud