From 1f29ecb357dd7b6ce1cf8f04a832e7300dff5293 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Mar 2012 01:09:25 +0000 Subject: [PATCH] Check for iterator validity when parsing "%%" in wxDateTime::Format() too. This is similar to the previous commit and adds another missed check for the iterator not being at the end of string. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetimefmt.cpp | 2 +- tests/datetime/datetimetest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index c75d2e2c18..ac7540dc88 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1448,7 +1448,7 @@ wxDateTime::ParseFormat(const wxString& date, break; case wxT('%'): // a percent sign - if ( *input++ != wxT('%') ) + if ( input == end || *input++ != wxT('%') ) { // no match return false; diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 71821d92e8..65375c0896 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -831,6 +831,7 @@ void DateTimeTestCase::TestTimeFormat() // test some degenerate cases CPPUNIT_ASSERT( !dt.ParseFormat("", "%z") ); + CPPUNIT_ASSERT( !dt.ParseFormat("", "%%") ); // test compilation of some calls which should compile (and not result in // ambiguity because of char*<->wxCStrData<->wxString conversions) -- 2.50.0