3
0
Fork 0
forked from mirrors/nixpkgs

grantleetheme: check for a null pointer

This commit is contained in:
Jos van den Oever 2017-04-18 09:40:22 +02:00 committed by Thomas Tuegel
parent fa8d240188
commit 828124b420
No known key found for this signature in database
GPG key ID: 22CBF5249D4B4D59
2 changed files with 28 additions and 1 deletions

View file

@ -10,9 +10,11 @@ mkDerivation {
license = with lib.licenses; [ gpl2 lgpl21 fdl12 ];
maintainers = kdepimTeam;
};
output = [ "out" "dev" ];
patches = [ ./grantleetheme_check_null.patch ];
nativeBuildInputs = [ extra-cmake-modules kdoctools ];
buildInputs = [
grantlee5 ki18n kiconthemes knewstuff kservice kxmlgui qtbase
];
output = [ "out" "dev" ];
propagatedBuildInputs = [ grantlee5 kiconthemes knewstuff ];
}

View file

@ -0,0 +1,25 @@
diff --git a/src/grantleetheme.cpp b/src/grantleetheme.cpp
index b86fc3a..8af72f4 100644
--- a/src/grantleetheme.cpp
+++ b/src/grantleetheme.cpp
@@ -102,7 +102,10 @@ QString ThemePrivate::errorTemplate(const QString &reason,
Grantlee::Context ctx = createContext();
ctx.insert(QStringLiteral("error"), reason);
ctx.insert(QStringLiteral("templateName"), origTemplateName);
- ctx.insert(QStringLiteral("errorMessage"), failedTemplate->errorString());
+ const QString errorString = failedTemplate
+ ? failedTemplate->errorString()
+ : QStringLiteral("(null template)");
+ ctx.insert(QStringLiteral("errorMessage"), errorString);
return tpl->render(&ctx);
}
@@ -208,7 +211,7 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con
}
Grantlee::Template tpl = d->loader->loadByName(templateName, ThemePrivate::sEngine);
- if (tpl->error()) {
+ if (!tpl || tpl->error()) {
return d->errorTemplate(i18n("Template parsing error"), templateName, tpl);
}