From: Tim Shimmin Date: Fri, 6 Oct 2006 16:19:47 +0000 (+0000) Subject: Fix up variable argument handling around vfprintf's. X-Git-Tag: v2.9.0~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f9ef38629d2b6ce705a487338f37a23cb92441c;p=thirdparty%2Fxfsprogs-dev.git Fix up variable argument handling around vfprintf's. Crashing on x86_64 otherwise and is just plain wrong. Merge of master-melb:xfs-cmds:27143a by kenmcd. Fix up variable argument handling around vfprintf's. Crashing on x86_64 otherwise and is just plain wrong. --- diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index adeb60a91..7795e8a8f 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -77,17 +77,23 @@ do_message(int flags, int code, const char *fmt, ...) va_list ap; int eek = 0; - va_start(ap, fmt); - if (flags & LOG) + if (flags & LOG) { + va_start(ap, fmt); if (vfprintf(logerr, fmt, ap) <= 0) eek = 1; + va_end(ap); + } if (eek) flags |= ERR; /* failed, force stderr */ - if (flags & ERR) + if (flags & ERR) { + va_start(ap, fmt); vfprintf(stderr, fmt, ap); - else if (flags & OUT) + va_end(ap); + } else if (flags & OUT) { + va_start(ap, fmt); vfprintf(stdout, fmt, ap); - va_end(ap); + va_end(ap); + } if (flags & PRE) { do_message(flags & ~PRE, 0, ": %s\n", strerror(code));