Avoid attempted reads past end of program image

Previously if what could be a load, store, branch, or call instruction
was located within last two bytes of the program image being
disassembled, the disassembler would try to read out of bounds to get
its address parameter. This change marks such cases as not being valid
This commit is contained in:
Juhani Krekelä 2022-08-08 18:48:23 +03:00
parent 29cb28fa49
commit 110280ed5e
1 changed files with 1 additions and 0 deletions

View File

@ -45,6 +45,7 @@ def segment(binary, origin):
valid = True
if not opcodes[opcode].rx and rx != 0: valid = False
if not opcodes[opcode].ry and ry != 0: valid = False
if opcodes[opcode].addr and ip + 2 >= len(binary): valid = False
if not valid:
raw = binary[ip:ip + 1]