Always NUL-terminate wxPrintfConvSpec::m_szFlags.

The array was initialized and terminating NUL was only added in some
cases. In combination with strchr() calls, this would result it
incorrect calculations or even crashes.

Fixed by initializing the array to zeros. This is less error-prone than
fixing the few places where explicitly adding the terminating NUL was
missing.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-06-24 10:34:06 +00:00
parent 2f06971640
commit 060ec116e4

View File

@@ -201,6 +201,7 @@ void wxPrintfConvSpec<CharType>::Init()
m_pArgPos = m_pArgEnd = NULL;
m_type = wxPAT_INVALID;
memset(m_szFlags, 0, sizeof(m_szFlags));
// this character will never be removed from m_szFlags array and
// is important when calling sprintf() in wxPrintfConvSpec::Process() !
m_szFlags[0] = '%';
@@ -387,7 +388,6 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
case wxT('X'):
CHECK_PREC
m_szFlags[flagofs++] = char(ch);
m_szFlags[flagofs] = '\0';
if (ilen == 0)
m_type = wxPAT_INT;
else if (ilen == -1)
@@ -415,7 +415,6 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
case wxT('G'):
CHECK_PREC
m_szFlags[flagofs++] = char(ch);
m_szFlags[flagofs] = '\0';
if (ilen == 2)
m_type = wxPAT_LONGDOUBLE;
else
@@ -426,7 +425,6 @@ bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
case wxT('p'):
m_type = wxPAT_POINTER;
m_szFlags[flagofs++] = char(ch);
m_szFlags[flagofs] = '\0';
done = true;
break;