printf.3: Fix a small bug in example code

Move the second call to va_end(ap) to above the if-block that
precedes it, so that the va_list 'ap' will be cleaned up in
all cases.

Reported-by: Erik Roland van der Meer <ervdmeer@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-02-02 09:33:04 +13:00
parent 5d048f53d3
commit 1ed246aedd
1 changed files with 2 additions and 1 deletions

View File

@ -1157,11 +1157,12 @@ make_message(const char *fmt, ...)
va_start(ap, fmt);
size = vsnprintf(p, size, fmt, ap);
va_end(ap);
if (size < 0) {
free(p);
return NULL;
}
va_end(ap);
return p;
}