From 9b0c5988bfae802595ff6407ae4d6a7a1b061dc3 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Wed, 22 Sep 2021 23:04:12 +0200 Subject: [PATCH] Fix operator== --- include/caosdb/protobuf_helper.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/caosdb/protobuf_helper.h b/include/caosdb/protobuf_helper.h index ff8fc15..4dfc11c 100644 --- a/include/caosdb/protobuf_helper.h +++ b/include/caosdb/protobuf_helper.h @@ -58,7 +58,11 @@ public: * serialization. */ inline auto operator==(const ProtoMessageWrapper<P> &other) const noexcept -> bool { - return this->wrapped->SerializeAsString() == other.wrapped->SerializeAsString(); + if (this->wrapped != nullptr && other.wrapped != nullptr) { + return this->wrapped->SerializeAsString() == other.wrapped->SerializeAsString(); + } + // both nullptr? + return this->wrapped == other.wrapped; } /** @@ -66,7 +70,11 @@ public: * serialization. */ inline auto operator!=(const ProtoMessageWrapper<P> &other) const noexcept -> bool { - return this->wrapped->SerializeAsString() != other.wrapped->SerializeAsString(); + if (this->wrapped != nullptr && other.wrapped != nullptr) { + return this->wrapped->SerializeAsString() != other.wrapped->SerializeAsString(); + } + // only one is nullptr? + return this->wrapped != other.wrapped; } protected: -- GitLab