ckeck for loops or too deep fallback chains

This commit is contained in:
Marco Martin 2014-08-27 17:39:32 +02:00
parent 11094417a3
commit 5b9bb128d8

View File

@ -514,12 +514,27 @@ void Package::setPath(const QString &path)
if (metadata().isValid()) {
fallback = metadata().property("X-KDE-fallbackPackage").toString();
if (fallback == metadata().pluginName()) {
fallback = QString();
}
}
if (!fallback.isEmpty()) {
if (!d->fallbackPackage) {
d->fallbackPackage = new Package(d->structure.data());
}
d->fallbackPackage->setPath(fallback);
Plasma::Package *pkg = d->fallbackPackage;
int depth = 0;
while (pkg->d->fallbackPackage) {
//cycle or too deep?
if (depth > 10 || pkg->d->fallbackPackage->metadata().pluginName() == metadata().pluginName()) {
delete pkg->d->fallbackPackage;
pkg->d->fallbackPackage = 0;
break;
}
pkg = pkg->d->fallbackPackage;
++depth;
}
} else {
delete d->fallbackPackage;
d->fallbackPackage = 0;