From e2c958e78632824ce44e71e4ad310404bad821d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Wed, 9 Oct 2002 13:26:46 +0000 Subject: ISO C standard as to say about va_list on 7.15 [#3] If access to the varying arguments is desired, the called function shall declare an object (referred to as ap in this subclause) having type va_list. The object ap may be passed as an argument to another function; if that function invokes the va_arg macro with parameter ap, the value of ap in the calling function is indeterminate and shall be passed to the va_end macro prior to any further reference to ap.199) Which interprets to do reuse a va_list that was already processed. Instead, use a copy. This fixes crashes on x86-64 and debugging feasible, since logging is now available. ;-) --- mdk-stage1/log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c index 319079fd7..bb56eb8a3 100644 --- a/mdk-stage1/log.c +++ b/mdk-stage1/log.c @@ -37,6 +37,9 @@ static FILE * logfile = NULL; void vlog_message(const char * s, va_list args) { + va_list args_copy; + va_copy(args_copy, args); + if (logfile) { fprintf(logfile, "* "); vfprintf(logfile, s, args); @@ -45,7 +48,7 @@ void vlog_message(const char * s, va_list args) } if (logtty) { fprintf(logtty, "* "); - vfprintf(logtty, s, args); + vfprintf(logtty, s, args_copy); fprintf(logtty, "\n"); fflush(logtty); } -- cgit v1.2.1