]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix crashes in wxDateTime::ParseDate() for some invalid dates.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 Nov 2010 22:37:52 +0000 (22:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 Nov 2010 22:37:52 +0000 (22:37 +0000)
Parsing an incomplete date with nothing but whitespace and/or date delimiter
characters at the end crashed as we happily went beyond the end of string.

Fix this by not using a loop which didn't check for the iterator validity.

Closes #12685.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66166 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/datetimefmt.cpp
tests/datetime/datetimetest.cpp

index 64bb825190c80beed847ce48e06e2d7fdcd8b41e..a073b3fcfc92bd884fa20e1f588cfe19af6fd9e1 100644 (file)
@@ -1625,9 +1625,10 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
     while ( p != pEnd )
     {
         // skip white space and date delimiters
-        while ( wxStrchr(".,/-\t\r\n ", *p) )
+        if ( wxStrchr(".,/-\t\r\n ", *p) )
         {
             ++p;
+            continue;
         }
 
         // modify copy of the iterator as we're not sure if the next token is
index 90ec18c939fe8900fc80b2e885a3d4af8d91d375..e21021e47afb0c53c77b0b5d31e9d28c267e0f4e 100644 (file)
@@ -973,6 +973,7 @@ void DateTimeTestCase::TestDateParse()
         { "29 Feb 2006" },
         { "31/04/06" },
         { "bloordyblop" },
+        { "2 .  .    " },
     };
 
     // special cases