]> git.saurik.com Git - wxWidgets.git/commitdiff
Check for iterator validity when parsing "%%" in wxDateTime::Format() too.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 9 Mar 2012 01:09:25 +0000 (01:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 9 Mar 2012 01:09:25 +0000 (01:09 +0000)
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
tests/datetime/datetimetest.cpp

index c75d2e2c18fde81fecb8ae6b84cd469178207eb1..ac7540dc881685190b9761357e833c46441da0fa 100644 (file)
@@ -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;
index 71821d92e88f3449b3b1642d8c53890390cf2ae4..65375c08961a90618873daad0762edc6080a747b 100644 (file)
@@ -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)