From cb885fb980b11eded918f41d3c04fa414f2bbdd2 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 3 Jan 2023 03:47:55 -0500 Subject: [PATCH] check for nullptr in HybridConditional::equals --- gtsam/hybrid/HybridConditional.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtsam/hybrid/HybridConditional.cpp b/gtsam/hybrid/HybridConditional.cpp index 6657aec8c..611f9b0e7 100644 --- a/gtsam/hybrid/HybridConditional.cpp +++ b/gtsam/hybrid/HybridConditional.cpp @@ -117,6 +117,22 @@ bool HybridConditional::equals(const HybridFactor &other, double tol) const { return other != nullptr && dc->equals(*other, tol); } return inner_->equals(*(e->inner_), tol); + + if (inner_) { + if (e->inner_) { + // Both the inner_ factors are not null + return inner_->equals(*(e->inner_), tol); + } else { + return false; + } + } else { + if (e->inner_) { + return false; + } else { + // Both inner_ are null + return true; + } + } } /* ************************************************************************ */