add bounds checks for stackless iterator (#2110)

This commit is contained in:
Mark
2023-10-14 12:05:57 -06:00
parent e4a677ceea
commit 669023914a

View File

@@ -280,9 +280,11 @@ impl<'a, UMP: UnmarkPolicy> StacklessPreOrderHeapIter<'a, UMP> {
return Some(cell); return Some(cell);
} }
if self.heap[self.next as usize].get_mark_bit() == self.iter_state.mark_phase() { if self.next < self.heap.len() as u64 {
let tag = HeapCellValueTag::AttrVar; if self.heap[self.next as usize].get_mark_bit() == self.iter_state.mark_phase() {
return Some(HeapCellValue::build_with(tag, next)); let tag = HeapCellValueTag::AttrVar;
return Some(HeapCellValue::build_with(tag, next));
}
} }
} }
HeapCellValueTag::Var => { HeapCellValueTag::Var => {
@@ -297,9 +299,11 @@ impl<'a, UMP: UnmarkPolicy> StacklessPreOrderHeapIter<'a, UMP> {
return Some(cell); return Some(cell);
} }
if self.heap[self.next as usize].get_mark_bit() == self.iter_state.mark_phase() { if self.next < self.heap.len() as u64 {
let tag = HeapCellValueTag::Var; if self.heap[self.next as usize].get_mark_bit() == self.iter_state.mark_phase() {
return Some(HeapCellValue::build_with(tag, next)); let tag = HeapCellValueTag::Var;
return Some(HeapCellValue::build_with(tag, next));
}
} }
} }
HeapCellValueTag::Str => { HeapCellValueTag::Str => {