mirror of
https://github.com/tmate-io/tmate.git
synced 2026-07-17 16:35:00 +00:00
Can't use the same va_list twice, from Emanuele Giaquinta.
This commit is contained in:
parent
5339b8ce3a
commit
e9ebdac3dd
1 changed files with 4 additions and 1 deletions
|
|
@ -44,12 +44,15 @@ int
|
|||
vasprintf(char **ret, const char *fmt, va_list ap)
|
||||
{
|
||||
int n;
|
||||
va_list ap2;
|
||||
|
||||
va_copy(ap2, ap);
|
||||
|
||||
if ((n = vsnprintf(NULL, 0, fmt, ap)) < 0)
|
||||
goto error;
|
||||
|
||||
*ret = xmalloc(n + 1);
|
||||
if ((n = vsnprintf(*ret, n + 1, fmt, ap)) < 0) {
|
||||
if ((n = vsnprintf(*ret, n + 1, fmt, ap2)) < 0) {
|
||||
xfree(*ret);
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue