add bounds check for attributed variables slice

This commit is contained in:
Mark Thom
2021-11-21 11:30:15 -07:00
parent 0e2db4a23e
commit 3355b49724

View File

@@ -82,10 +82,13 @@ impl MachineState {
}
pub(super) fn gather_attr_vars_created_since(&mut self, b: usize) -> IntoIter<HeapCellValue> {
let mut attr_vars: Vec<_> = self.attr_var_init.attr_var_queue[b..]
let mut attr_vars: Vec<_> = if b >= self.attr_var_init.attr_var_queue.len() {
vec![]
} else {
self.attr_var_init.attr_var_queue[b..]
.iter()
.filter_map(|h| {
read_heap_cell!(self.store(self.deref(heap_loc_as_cell!(*h))), //Addr::HeapCell(*h))) {
read_heap_cell!(self.store(self.deref(heap_loc_as_cell!(*h))),
(HeapCellValueTag::AttrVar, h) => {
Some(attr_var_as_cell!(h))
}
@@ -94,7 +97,8 @@ impl MachineState {
}
)
})
.collect();
.collect()
};
attr_vars.sort_unstable_by(|a1, a2| {
compare_term_test!(self, *a1, *a2).unwrap_or(Ordering::Less)