Skip to content

Commit

Permalink
goalc: add some nullptr checks around symbol map lookups (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored Apr 3, 2024
1 parent 6ea8dfb commit a7efd59
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions common/util/trie_with_duplicates.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand All @@ -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);
}
}
}
};

0 comments on commit a7efd59

Please sign in to comment.