[Asterisk-Dev] Asterisk support for Solaris 10 X86

Steve Drach sdrach at gmail.com
Wed Aug 3 08:04:54 MST 2005


The previous patch (see bugs 4882 and 4890) freed a pointer before it
should be freed.  Here is the correct implementation of vasprintf.

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(&s, 1, fmt, ap2);
        va_end(ap2);
        *strp = malloc(size + 1);
        if (!*strp)
                return -1;
        vsnprintf(*strp, size + 1, fmt, ap);

        return size;
}



More information about the asterisk-dev mailing list