]> Git trees. - libqmvoc.git/commitdiff
Fixed crash condition in ExtDate::fromString(QString, QDateFormat).
authorJason Harris <kstars@30doradus.org>
Fri, 15 Sep 2006 21:45:57 +0000 (21:45 +0000)
committerJason Harris <kstars@30doradus.org>
Fri, 15 Sep 2006 21:45:57 +0000 (21:45 +0000)
When using the TextFormat QDateFormat, the code creates a QStringList
from the space-separated fields of the input string, but it then assumed
that the stringlist contains at least three members, which caused a
crash when this was not the case.  Now, it will return an invalid
ExtDate if the stringlist contains fewer than three members.

Thanks for the tip, Jasem.

CCMAIL: kde-edu@kde.org
CCMAIL: kstars-devel@kde.org

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=584944

extdate/extdatetime.cpp

index 128959d008cf2d79153c0d77759dd36e9ce97f55..8c8f127d70f97aedd51fe084a7d909485e7d7937 100644 (file)
@@ -494,6 +494,10 @@ ExtDate ExtDate::fromString( const QString& s, Qt::DateFormat f )
                        //Three possible date formats:
                        //dd mth yyyy; mth dd yyyy; wkd mth dd yyyy
                        QStringList ss = s.split( " " );
+
+                       //Return invalid if we don't have at least 3 fields
+                       if ( ss.size() < 3 ) return dt;
+
                        bool ok = false;
                        int month = -1;
                        uint imonth = 0;