Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
fix(brillig): expand memory with zeroes on store (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Jun 8, 2023
1 parent 82150b1 commit 4d2dadd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions brillig_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,15 @@ impl VM {
}
Opcode::Store { destination_pointer, source: source_register } => {
// Convert our destination_pointer to a usize
let destination = self.registers.get(*destination_pointer);
let destination = self.registers.get(*destination_pointer).to_usize();
if destination >= self.memory.len() {
self.memory.append(&mut vec![
Value::from(0_usize);
destination - self.memory.len() + 1
]);
}
// Use our usize destination index to set the value in memory
self.memory[destination.to_usize()] = self.registers.get(*source_register);
self.memory[destination] = self.registers.get(*source_register);
self.increment_program_counter()
}
Opcode::Call { location } => {
Expand Down

0 comments on commit 4d2dadd

Please sign in to comment.