[FFmpeg-devel] [PATCH] mingw: Use avprive_vsnprintf in bprint
Derek Buitenhuis
derek.buitenhuis at gmail.com
Mon Sep 17 01:33:04 CEST 2012
MinGW versions prior to r4663 (w64) have a buggy vsnprintf
implemenation.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
compat/msvcrt/snprintf.c | 7 +++++++
libavutil/bprint.c | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/compat/msvcrt/snprintf.c b/compat/msvcrt/snprintf.c
index 6787aad..30dc1f9 100644
--- a/compat/msvcrt/snprintf.c
+++ b/compat/msvcrt/snprintf.c
@@ -27,6 +27,13 @@
#include "compat/va_copy.h"
#include "libavutil/error.h"
+#if defined(__MINGW32__)
+#define EOVERFLOW EFBIG
+
+int avpriv_snprintf(char *s, size_t n, const char *fmt, ...);
+int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap);
+#endif
+
int avpriv_snprintf(char *s, size_t n, const char *fmt, ...)
{
va_list ap;
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index 373a492..9d3b408 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -27,6 +27,12 @@
#include "error.h"
#include "mem.h"
+#if defined(__MINGW32__)
+#include "compat/msvcrt/snprintf.c"
+#undef vsnprintf
+#define vsnprintf avpriv_vsnprintf
+#endif
+
#define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
#define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
--
1.7.9.5
More information about the ffmpeg-devel
mailing list