GP-6737: Fixing potential infinite loop in ExportTrie.java

This commit is contained in:
Ryan Kurtz
2026-04-21 05:17:38 -04:00
parent 9c066df19d
commit 67fd364d03

View File

@@ -89,9 +89,14 @@ public class ExportTrie {
* @throws IOException if there was an IO-related error
*/
private void parseTrie() throws IOException {
Set<Integer> visited = new HashSet<>();
visited.add(0);
LinkedList<Node> remainingNodes = parseNode("", 0);
while(!remainingNodes.isEmpty()) {
Node parent = remainingNodes.removeFirst();
if (!visited.add(parent.offset())) {
continue; // skip already-visited offsets
}
LinkedList<Node> children = parseNode(parent.name, parent.offset);
for (Node child : children) {
remainingNodes.add(new Node(parent.name + child.name, child.offset));