Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sources/vasprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
int
vasprintf(char** strp, const char* format, va_list ap)
{
int size = vsnprintf(NULL, 0, format, ap);
va_list ap2;
int size;

/* the argument list is traversed twice */
__va_copy(ap2, ap);
size = vsnprintf(NULL, 0, format, ap2);
va_end(ap2);

if (size >= 0 && size < INT_MAX) {
*strp = malloc(size + 1);
Expand Down
Loading