From 1ed246aedde91f1deba237404fb8bda2904c20a2 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 2 Feb 2017 09:33:04 +1300 Subject: 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 Signed-off-by: Michael Kerrisk --- man3/printf.3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'man3/printf.3') diff --git a/man3/printf.3 b/man3/printf.3 index c9e6bdad9c..c220ba78e6 100644 --- a/man3/printf.3 +++ b/man3/printf.3 @@ -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; } -- cgit 1.2.3-korg