From d07c4cb82649ec6833a11b637678558b2c7df1eb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 May 2015 02:47:00 +0200 Subject: [PATCH] Really fix check for maximal argument number in wxPrintf(). Increment nargs before comparing it with wxMAX_SVNPRINTF_ARGUMENTS, if the comparison is true for the post increment, the value is already invalid. --- include/wx/private/wxprintf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/wx/private/wxprintf.h b/include/wx/private/wxprintf.h index 7e658b9013..e16b9f4e40 100644 --- a/include/wx/private/wxprintf.h +++ b/include/wx/private/wxprintf.h @@ -838,7 +838,7 @@ struct wxPrintfConvSpecParser for ( unsigned n = 0; n < numAsterisks; n++ ) { - if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS ) + if ( ++nargs == wxMAX_SVNPRINTF_ARGUMENTS ) break; // TODO: we need to support specifiers of the form "%2$*1$s" @@ -895,7 +895,7 @@ struct wxPrintfConvSpecParser // this conversion specifier is tied to the pos-th argument... pspec[spec->m_pos] = spec; - if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS ) + if ( ++nargs == wxMAX_SVNPRINTF_ARGUMENTS ) break; }