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