summaryrefslogtreecommitdiff
path: root/user/tf/0002-Correct-use-of-va_list.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/tf/0002-Correct-use-of-va_list.patch')
-rw-r--r--user/tf/0002-Correct-use-of-va_list.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/user/tf/0002-Correct-use-of-va_list.patch b/user/tf/0002-Correct-use-of-va_list.patch
new file mode 100644
index 000000000..d13fcd854
--- /dev/null
+++ b/user/tf/0002-Correct-use-of-va_list.patch
@@ -0,0 +1,34 @@
+From: Russ Allbery <rra@debian.org>
+Date: Sun, 17 Feb 2008 22:23:24 -0800
+Subject: Correct use of va_list
+
+va_copy a va_list before using it in vsprintf so that we don't use the
+same va_list repeatedly. Patch taken from the upstream bug tracker
+and will apparently be in the next release after 5.0beta8.
+---
+ src/tfio.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/tfio.c b/src/tfio.c
+index 2cd2103..151583e 100644
+--- a/src/tfio.c
++++ b/src/tfio.c
+@@ -497,6 +497,7 @@ void vSprintf(String *buf, int flags, const char *fmt, va_list ap)
+ const conString *Sval;
+ int len, min, max, leftjust, stars;
+ attr_t attrs = buf->attrs;
++ va_list ap_copy;
+
+ if (!(flags & SP_APPEND) && buf->data) Stringtrunc(buf, 0);
+ while (*fmt) {
+@@ -522,7 +523,9 @@ void vSprintf(String *buf, int flags, const char *fmt, va_list ap)
+ case 'x': case 'X': case 'u': case 'o':
+ case 'f': case 'e': case 'E': case 'g': case 'G':
+ case 'p':
+- vsprintf(tempbuf, spec, ap);
++ va_copy(ap_copy, ap);
++ vsprintf(tempbuf, spec, ap_copy);
++ va_end(ap_copy);
+ Stringcat(buf, tempbuf);
+ /* eat the arguments used by vsprintf() */
+ while (stars--) (void)va_arg(ap, int);