Fix seg fault on null pointer in operators
authorJohannes Schanda <schanda@itestra.de>
Fri, 13 Sep 2013 15:24:29 +0000 (17:24 +0200)
committerJohannes Schanda <schanda@itestra.de>
Fri, 13 Sep 2013 16:20:59 +0000 (18:20 +0200)
src/CommonAPI/ContainerUtils.cpp

index bb1a360..cfe6914 100644 (file)
 namespace CommonAPI {
 
 size_t SharedPointerClientIdContentHash::operator()(const std::shared_ptr<ClientId>& t) const {
-    return t->hashCode();
+    if (t) {
+        return t->hashCode();
+    } else {
+        return NULL;
+    }
 }
 
 bool SharedPointerClientIdContentEqual::operator()(const std::shared_ptr<ClientId>& a, const std::shared_ptr<ClientId>& b) const {
-    return *a==*b;
+    if (a && b) {
+        return *a==*b;
+    } else {
+        return false;
+    }
 }
 
 }  // namespace std