From a7efd59919b58bbae7ce2fe1250570acb1555487 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Wed, 3 Apr 2024 19:45:44 -0400 Subject: [PATCH] goalc: add some nullptr checks around symbol map lookups (#3447) --- common/util/trie_with_duplicates.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/util/trie_with_duplicates.h b/common/util/trie_with_duplicates.h index fe013a6473..bc01dc9956 100644 --- a/common/util/trie_with_duplicates.h +++ b/common/util/trie_with_duplicates.h @@ -112,14 +112,18 @@ class TrieWithDuplicates { results.push_back(element.get()); } for (const auto& child : node->children) { - retrieve_elements(child.get(), results); + if (child.get() != nullptr) { + retrieve_elements(child.get(), results); + } } } void count_elements(const TrieNode* node, int& count) const { count += node->elements.size(); for (const auto& child : node->children) { - count_elements(child.get(), count); + if (child.get() != nullptr) { + count_elements(child.get(), count); + } } } @@ -128,7 +132,9 @@ class TrieWithDuplicates { result.push_back(element.get()); } for (const auto& child : node->children) { - get_all_elements_helper(child.get(), result); + if (child.get() != nullptr) { + get_all_elements_helper(child.get(), result); + } } } };