diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-09 17:09:57 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-09 17:09:57 +0200 |
commit | 7b620d6baf986dfac679fe0ad4a66a8ffc892d86 (patch) | |
tree | ef86c5267f348ec722ed877c2e302cfe4a2c2e3c /common/facadefactory.h | |
parent | 10c69359c8f89424ab1320613e6651847fe72a3b (diff) | |
download | sink-7b620d6baf986dfac679fe0ad4a66a8ffc892d86.tar.gz sink-7b620d6baf986dfac679fe0ad4a66a8ffc892d86.zip |
Check for null pointers.
Diffstat (limited to 'common/facadefactory.h')
-rw-r--r-- | common/facadefactory.h | 7 |
1 files changed, 6 insertions, 1 deletions
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: | |||
77 | std::shared_ptr<StoreFacade<DomainType>> getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier) | 77 | std::shared_ptr<StoreFacade<DomainType>> getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier) |
78 | { | 78 | { |
79 | const QByteArray typeName = ApplicationDomain::getTypeName<DomainType>(); | 79 | const QByteArray typeName = ApplicationDomain::getTypeName<DomainType>(); |
80 | return std::static_pointer_cast<StoreFacade<DomainType>>(getFacade(resource, instanceIdentifier, typeName)); | 80 | const auto ptr = getFacade(resource, instanceIdentifier, typeName); |
81 | //We have to check the pointer before the cast, otherwise a check would return true also for invalid instances. | ||
82 | if (!ptr) { | ||
83 | return std::shared_ptr<StoreFacade<DomainType>>(); | ||
84 | } | ||
85 | return std::static_pointer_cast<StoreFacade<DomainType>>(ptr); | ||
81 | } | 86 | } |
82 | 87 | ||
83 | private: | 88 | private: |