From 04bc8d3195c88aca3fbac8019bcf325a9245b55f Mon Sep 17 00:00:00 2001 From: Martin von Gagern Date: Tue, 17 May 2016 22:37:32 +0200 Subject: [PATCH] Pair va_copy calls with va_end According to the specs, each va_copy call should be matched by a va_end call to ensure proper cleanup. Furthermore, since message filters might iterate over the list of arguments, we should hand a new copy to each filter. --- src/message.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/message.c b/src/message.c index 8252c2d..2948deb 100755 --- a/src/message.c +++ b/src/message.c @@ -231,7 +231,7 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code, { va_list args_copy; va_copy(args_copy, args); - TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args); + TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args_copy); if ( doc->mssgFilt ) { TidyDoc tdoc = tidyImplToDoc( doc ); @@ -245,6 +245,8 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code, consistent, we have to ensure that we only ever return the built-in English version of this string. */ TidyDoc tdoc = tidyImplToDoc( doc ); + va_end(args_copy); + va_copy(args_copy, args); go = go | doc->mssgFilt2( tdoc, level, line, col, tidyDefaultString(code), args_copy ); } if ( doc->mssgFilt3 ) @@ -253,8 +255,11 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code, messages via their own means by providing a key string and the parameters to fill it. */ TidyDoc tdoc = tidyImplToDoc( doc ); + va_end(args_copy); + va_copy(args_copy, args); go = go | doc->mssgFilt3( tdoc, level, line, col, tidyErrorCodeAsString(code), args_copy ); } + va_end(args_copy); } if ( go )