summaryrefslogtreecommitdiffstats
path: root/bytecode/src/heap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bytecode/src/heap.rs')
-rw-r--r--bytecode/src/heap.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/bytecode/src/heap.rs b/bytecode/src/heap.rs
index 970db7d..f195613 100644
--- a/bytecode/src/heap.rs
+++ b/bytecode/src/heap.rs
@@ -132,11 +132,14 @@ impl Heap {
Ok(Value(self.buf[p]))
}
- pub fn poke(&mut self, p: usize, val: Value) -> Result<(), Box<dyn Error>> {
+ pub fn poke(&mut self, p: usize, off: usize, val: Value) -> Result<(), Box<dyn Error>> {
if p >= self.buf.len() {
return Err(Box::from("poke: out of range"));
}
- self.buf[p] = val.repr();
+ if off >= self.alloc_size(p) {
+ return Err(Box::from("poke: out of range"));
+ }
+ self.buf[p + off] = val.repr();
Ok(())
}
}