grantleetheme: check for a null pointer

authored by Jos van den Oever and committed by Thomas Tuegel 828124b4 fa8d2401

+28 -1
+3 -1
pkgs/applications/kde/grantleetheme.nix
··· 10 10 license = with lib.licenses; [ gpl2 lgpl21 fdl12 ]; 11 11 maintainers = kdepimTeam; 12 12 }; 13 + output = [ "out" "dev" ]; 14 + patches = [ ./grantleetheme_check_null.patch ]; 13 15 nativeBuildInputs = [ extra-cmake-modules kdoctools ]; 14 16 buildInputs = [ 15 17 grantlee5 ki18n kiconthemes knewstuff kservice kxmlgui qtbase 16 18 ]; 17 - output = [ "out" "dev" ]; 19 + propagatedBuildInputs = [ grantlee5 kiconthemes knewstuff ]; 18 20 }
+25
pkgs/applications/kde/grantleetheme_check_null.patch
··· 1 + diff --git a/src/grantleetheme.cpp b/src/grantleetheme.cpp 2 + index b86fc3a..8af72f4 100644 3 + --- a/src/grantleetheme.cpp 4 + +++ b/src/grantleetheme.cpp 5 + @@ -102,7 +102,10 @@ QString ThemePrivate::errorTemplate(const QString &reason, 6 + Grantlee::Context ctx = createContext(); 7 + ctx.insert(QStringLiteral("error"), reason); 8 + ctx.insert(QStringLiteral("templateName"), origTemplateName); 9 + - ctx.insert(QStringLiteral("errorMessage"), failedTemplate->errorString()); 10 + + const QString errorString = failedTemplate 11 + + ? failedTemplate->errorString() 12 + + : QStringLiteral("(null template)"); 13 + + ctx.insert(QStringLiteral("errorMessage"), errorString); 14 + return tpl->render(&ctx); 15 + } 16 + 17 + @@ -208,7 +211,7 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con 18 + } 19 + 20 + Grantlee::Template tpl = d->loader->loadByName(templateName, ThemePrivate::sEngine); 21 + - if (tpl->error()) { 22 + + if (!tpl || tpl->error()) { 23 + return d->errorTemplate(i18n("Template parsing error"), templateName, tpl); 24 + } 25 +