Browse Source

Fix xvasprintf function

The xvasprintf function made improper use of the va_* macros
to handle variable argument lists.
master
Damien Goutte-Gattat 5 years ago
parent
commit
946538a298
  1. 9
      lib/xmem.c

9
lib/xmem.c

@ -123,13 +123,14 @@ xvasprintf(char **s, const char *fmt, va_list ap)
int n;
va_list aq;
n = vsnprintf(NULL, 0, fmt, ap) + 1;
va_copy(aq, ap);
n = vsnprintf(NULL, 0, fmt, aq) + 1;
va_end(aq);
if ( ! (*s = malloc(n)) )
mem_error((size_t) n);
va_copy(ap, aq);
n = vsnprintf(*s, n, fmt, aq);
va_end(aq);
n = vsnprintf(*s, n, fmt, ap);
return n;
}
Loading…
Cancel
Save