summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2002-10-09 13:26:46 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2002-10-09 13:26:46 +0000
commite2c958e78632824ce44e71e4ad310404bad821d9 (patch)
treec7acaf26761935fb4a3304f408fdea9a24256d09
parentf8c790f01aa82ff97814e3abf6acde146f1312fd (diff)
downloaddrakx-e2c958e78632824ce44e71e4ad310404bad821d9.tar
drakx-e2c958e78632824ce44e71e4ad310404bad821d9.tar.gz
drakx-e2c958e78632824ce44e71e4ad310404bad821d9.tar.bz2
drakx-e2c958e78632824ce44e71e4ad310404bad821d9.tar.xz
drakx-e2c958e78632824ce44e71e4ad310404bad821d9.zip
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. ;-)
-rw-r--r--mdk-stage1/log.c5
1 files changed, 4 insertions, 1 deletions
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);
}