QMimeDatabase: Fix crash on empty filename
This is due to the search in the suffix tree starting at position fileName.length() - 1. Change-Id: I98501c1724c7dde2626351ace8ba19faa0d2e1e1 Reviewed-by: Ivan Komissarov <ABBAPOH@nextmail.ru> Reviewed-by: Wolf-Michael Bolle <wolf-michael.bolle@nokia.com>
This commit is contained in:
parent
e6f84312a5
commit
c78957766a
@ -283,6 +283,8 @@ QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name)
|
||||
QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix)
|
||||
{
|
||||
checkCache();
|
||||
if (fileName.isEmpty())
|
||||
return QStringList();
|
||||
const QString lowerFileName = fileName.toLower();
|
||||
QMimeGlobMatchResult result;
|
||||
// TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.
|
||||
|
@ -207,6 +207,7 @@ void tst_QMimeDatabase::mimeTypeForFileName_data()
|
||||
QTest::newRow("directory") << "/" << "inode/directory";
|
||||
QTest::newRow("doesn't exist, no extension") << "IDontExist" << "application/octet-stream";
|
||||
QTest::newRow("doesn't exist but has known extension") << "IDontExist.txt" << "text/plain";
|
||||
QTest::newRow("empty") << "" << "application/octet-stream";
|
||||
}
|
||||
|
||||
static inline QByteArray msgMimeTypeForFileNameFailed(const QList<QMimeType> &actual,
|
||||
|
Loading…
Reference in New Issue
Block a user