aboutsummaryrefslogtreecommitdiffstats
path: root/man3/printf.3
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2017-02-02 09:33:04 +1300
committerMichael Kerrisk <mtk.manpages@gmail.com>2017-02-02 09:33:04 +1300
commit1ed246aedde91f1deba237404fb8bda2904c20a2 (patch)
tree18b53f59469a20238aceb7d15c0a536288e1fff9 /man3/printf.3
parent5d048f53d3daf21d8e49b98c931c7d73f2abc669 (diff)
downloadman-pages-1ed246aedde91f1deba237404fb8bda2904c20a2.tar.gz
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>
Diffstat (limited to 'man3/printf.3')
-rw-r--r--man3/printf.33
1 files changed, 2 insertions, 1 deletions
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;
}