diff --git a/src/bin/ponderosa-cpu.rs b/src/bin/ponderosa-cpu.rs index de012b3..54edf8b 100644 --- a/src/bin/ponderosa-cpu.rs +++ b/src/bin/ponderosa-cpu.rs @@ -234,7 +234,14 @@ fn main() -> io::Result<()> { let tree = trees.remove(&tree_id).unwrap(); (tree.parent_id, tree.stack_size) }; - let parent = trees.get_mut(&parent_id).unwrap(); + + // One tree is "its own" parent, namely, the seed tree, in which + // case this `get_mut` will return None + let parent = match trees.get_mut(&parent_id) { + Some(p) => p, + None => continue + }; + parent.stack_size += recovered_stack_size; }