Fixed poking segfault

Machine would segfault when poking address 0 on an uninitialized
block. this has been fixed.
This commit is contained in:
Sasha Koshka 2022-08-29 12:01:08 -04:00
parent 635aced0d4
commit e342d9b254

View File

@ -263,7 +263,7 @@ func (machine *Machine[WORD]) Peek(address WORD) (word WORD) {
// Poke sets the value at address in the block to word.
func (machine *Machine[WORD]) Poke(address WORD, word WORD) {
if int(address) >= len(machine.block) {
reallocatedBlock := make([]WORD, address*3/2)
reallocatedBlock := make([]WORD, address*3/2+1)
copy(reallocatedBlock, machine.block)
machine.block = reallocatedBlock
}