Fix segfault when showZero==false

release/4.3a0
Frank Dellaert 2022-01-04 18:40:08 -05:00
parent dcc74d827d
commit 541127f855
1 changed files with 2 additions and 3 deletions

View File

@ -262,8 +262,7 @@ namespace gtsam {
// Check if zero // Check if zero
if (!showZero) { if (!showZero) {
const Leaf* leaf = dynamic_cast<const Leaf*>(branch.get()); const Leaf* leaf = dynamic_cast<const Leaf*>(branch.get());
std::string value = valueFormatter(leaf->constant()); if (leaf && valueFormatter(leaf->constant()).compare("0")) continue;
if (leaf && value.compare("0")) continue;
} }
os << "\"" << this->id() << "\" -> \"" << branch->id() << "\""; os << "\"" << this->id() << "\" -> \"" << branch->id() << "\"";