diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index fed909fe8a..c75d2e2c18 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1408,6 +1408,11 @@ wxDateTime::ParseFormat(const wxString& date, case wxT('z'): { + // check that we have something here at all + if ( input == end ) + return false; + + // and then check that it's either plus or minus sign bool minusFound; if ( *input == wxT('-') ) minusFound = true; diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 3d4fad74d1..71821d92e8 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -829,6 +829,9 @@ void DateTimeTestCase::TestTimeFormat() CPPUNIT_ASSERT( dt.ParseFormat("17", "%d") ); CPPUNIT_ASSERT_EQUAL( 17, dt.GetDay() ); + // test some degenerate cases + CPPUNIT_ASSERT( !dt.ParseFormat("", "%z") ); + // test compilation of some calls which should compile (and not result in // ambiguity because of char*<->wxCStrData<->wxString conversions) wxString s("foo");