Fix vasnprintf emulation (bug #4882)
authorMark Spencer <markster@digium.com>
Wed, 3 Aug 2005 02:07:25 +0000 (02:07 +0000)
committerMark Spencer <markster@digium.com>
Wed, 3 Aug 2005 02:07:25 +0000 (02:07 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6258 65c4cc65-6c06-0410-ace0-fbb531ad65f3

utils.c

diff --git a/utils.c b/utils.c
index cc5bf3b..069eb65 100755 (executable)
--- a/utils.c
+++ b/utils.c
@@ -617,17 +617,17 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
 {
        int size;
        va_list ap2;
+       char s;
 
        *strp = NULL;
        va_copy(ap2, ap);
-       size = vsnprintf(*strp, 0, fmt, ap2);
+       size = vsnprintf(&s, 1, fmt, ap2);
        va_end(ap2);
        *strp = malloc(size + 1);
        if (!*strp)
                return -1;
-       va_start(fmt, ap);
        vsnprintf(*strp, size + 1, fmt, ap);
-       va_end(ap);
+       free(*strp);
 
        return size;
 }