Guard against empty keys in QPlatformInputContextFactory::create().

The code relied on QStringList::split() returning a list
consisting of one empty string when passing an enpty string.
Add a check to prevent the plugin loader from trying to load
in this case.

Change-Id: Iadb418d32fdea1d472d6c00726ad039b4afbf409
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-09-24 08:42:06 +02:00
parent e87df57abf
commit bf2c9fd2fd

View File

@ -65,15 +65,17 @@ QString QPlatformInputContextFactory::requested()
QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QStringList paramList = key.split(QLatin1Char(':'));
const QString platform = paramList.takeFirst().toLower();
if (!key.isEmpty()) {
QStringList paramList = key.split(QLatin1Char(':'));
const QString platform = paramList.takeFirst().toLower();
QPlatformInputContext *ic = qLoadPlugin1<QPlatformInputContext, QPlatformInputContextPlugin>
(loader(), platform, paramList);
if (ic && ic->isValid())
return ic;
QPlatformInputContext *ic = qLoadPlugin1<QPlatformInputContext, QPlatformInputContextPlugin>
(loader(), platform, paramList);
if (ic && ic->isValid())
return ic;
delete ic;
delete ic;
}
#endif
return 0;
}