[FFmpeg-devel] [PATCH] mingw: Use avprive_vsnprintf in bprint

jamal jamrial at gmail.com
Mon Sep 17 04:00:54 CEST 2012


On 16/09/12 8:33 PM, Derek Buitenhuis wrote:
> 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)
>  
> 
Seems like r4663 is only on Mingw64 trunk (wasn't backported to stable v2.0 or v1.0). Knowing that, wouldn't it be better to check for __MINGW64_VERSION_MAJOR < 3 instead of __MINGW32__?

Regards.


More information about the ffmpeg-devel mailing list