From 73b2d853c8b82308f5fe14a58fa5929fea27e72b Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 5 Sep 2013 15:54:56 -0700 Subject: [PATCH] cmErr.c: Fix bug in use of va_list which showed up on spat-lab Mac port. --- cmErr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmErr.c b/cmErr.c index 27c1a25..e833b2b 100644 --- a/cmErr.c +++ b/cmErr.c @@ -17,6 +17,9 @@ void _cmErrVMsg(cmErr_t* err, bool warnFl, cmRC_t rc, const cmChar_t* fmt, va_li { if( err->rpt == NULL ) return; + + va_list vl0; + va_copy(vl0,vl); const cmChar_t* hdrFmt = warnFl ? "%s warning: " : "%s error: "; const cmChar_t* codeFmt = " (RC:%i)"; @@ -26,11 +29,13 @@ void _cmErrVMsg(cmErr_t* err, bool warnFl, cmRC_t rc, const cmChar_t* fmt, va_li int n2 = snprintf( NULL,0,codeFmt,rc); int n = n0+n1+n2+1; cmChar_t s[n]; + n0 = snprintf(s,n,hdrFmt,cmStringNullGuard(err->label)); - n0 += vsnprintf(s+n0,n-n0,fmt,vl); + n0 += vsnprintf(s+n0,n-n0,fmt,vl0); n0 += snprintf(s+n0,n-n0,codeFmt,rc); assert(n0 <= n ); cmRptErrorf(err->rpt,"%s\n",s); + va_end(vl0); } void _cmErrMsg( cmErr_t* err, bool warnFl, cmRC_t rc, const cmChar_t* fmt, ... )