office-gobmx/liblangtag/liblangtag-0.4.0-vsnprintf.patch
Luboš Luňák 7580038e24 vsnprintf() is not portable
http://perfec.to/vsnprintf/
At least MSVC2010 implementation returns -1 when the result doesn't fit,
so the excepted size is not computed correctly. Let's hope 16k is
big enough for everybody(TM).

Change-Id: I636487c7723651bfa74513018be786a45b6c796d
2012-12-01 13:24:54 +01:00

30 lines
748 B
Diff

--- misc/liblangtag-0.4.0/liblangtag/lt-utils.c 2012-12-01 10:46:26.000000000 +0100
+++ misc/build/liblangtag-0.4.0/liblangtag/lt-utils.c 2012-12-01 13:17:41.421568551 +0100
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <memory.h>
+#include <stdlib.h>
#include "lt-messages.h"
#include "lt-utils.h"
@@ -121,7 +121,7 @@ char *
lt_strdup_vprintf(const char *format,
va_list args)
{
- char *retval, c;
+ char *retval, tmpbuf[ 16384 ];
va_list ap;
int size;
@@ -133,7 +133,9 @@ lt_strdup_vprintf(const char *format,
va_copy(ap, args);
#endif
- size = vsnprintf(&c, 1, format, ap) + 1;
+ size = vsnprintf(tmpbuf, sizeof(tmpbuf), format, ap) + 1;
+ if( size == 0 ) // -1 + 1
+ abort();
va_end(ap);