From 7b620d6baf986dfac679fe0ad4a66a8ffc892d86 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 9 Apr 2016 17:09:57 +0200 Subject: Check for null pointers. --- common/facadefactory.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/facadefactory.h b/common/facadefactory.h index 83b8898..03e0784 100644 --- a/common/facadefactory.h +++ b/common/facadefactory.h @@ -77,7 +77,12 @@ public: std::shared_ptr> getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier) { const QByteArray typeName = ApplicationDomain::getTypeName(); - return std::static_pointer_cast>(getFacade(resource, instanceIdentifier, typeName)); + const auto ptr = getFacade(resource, instanceIdentifier, typeName); + //We have to check the pointer before the cast, otherwise a check would return true also for invalid instances. + if (!ptr) { + return std::shared_ptr>(); + } + return std::static_pointer_cast>(ptr); } private: -- cgit v1.2.3