From 541127f85504bfa2483ddc261935c8f4eb2263c0 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Tue, 4 Jan 2022 18:40:08 -0500 Subject: [PATCH] Fix segfault when showZero==false --- gtsam/discrete/DecisionTree-inl.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 3c74e57fd..ab14b2a72 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -261,9 +261,8 @@ namespace gtsam { // Check if zero if (!showZero) { - const Leaf* leaf = dynamic_cast (branch.get()); - std::string value = valueFormatter(leaf->constant()); - if (leaf && value.compare("0")) continue; + const Leaf* leaf = dynamic_cast(branch.get()); + if (leaf && valueFormatter(leaf->constant()).compare("0")) continue; } os << "\"" << this->id() << "\" -> \"" << branch->id() << "\"";