summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Kibbey <bjk@luxsci.net>2014-10-16 19:26:41 -0400
committerBen Kibbey <bjk@luxsci.net>2014-10-16 19:32:13 -0400
commitfff2049c1bc7c627e11df8062ef1f96a7697954f (patch)
tree6b1539a4d5eafc62a93d6e626adae43ee99255fa
parentaea2c168fc9c12148181dbcc33d7085aad8e6d90 (diff)
downloadgpgme-bjk/master.tar.gz
Fix crash with built-in [v]asprintf().bjk/master
* src/vasprintf.c (__gpgme_vasprintf): Copy the va_list. -- Not sure why it needs to be done. Maybe because of dereferencing the pointer while doing va_copy() int_vasprintf()? If we remove the _BSD_VA_LIST stuff and pass a regular va_list all is fine.
-rw-r--r--src/vasprintf.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/vasprintf.c b/src/vasprintf.c
index 326a2c35..18b1ef17 100644
--- a/src/vasprintf.c
+++ b/src/vasprintf.c
@@ -26,8 +26,6 @@ Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <stdarg.h>
-#include "mem.h"
-
#ifndef va_copy /* According to POSIX, va_copy is a macro. */
#if defined (__GNUC__) && defined (__PPC__) \
@@ -42,7 +40,14 @@ Boston, MA 02111-1307, USA. */
#ifdef TEST
+#define _gpgme_malloc malloc
+#define _gpgme_calloc calloc
+#define _gpgme_realloc realloc
+#define _gpgme_strdup strdup
+#define _gpgme_free free
int global_total_width;
+#else
+#include "mem.h"
#endif
static int int_vasprintf (char **, const char *, va_list *);
@@ -161,7 +166,17 @@ _gpgme_vasprintf (result, format, args)
va_list args;
#endif
{
- return int_vasprintf (result, format, &args);
+#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
+ _BSD_VA_LIST_ cp;
+#else
+ va_list cp;
+#endif
+ int ret;
+
+ va_copy(cp, args);
+ ret = int_vasprintf (result, format, &cp);
+ va_end(cp);
+ return ret;
}