diff --git a/src/da65/main.c b/src/da65/main.c index ac1511b57..1051c7488 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -290,11 +290,21 @@ static void OneOpcode (unsigned RemainingBytes) switch (Style) { case atDefault: - case atCode: D->Handler (D); PC += D->Size; break; + case atCode: + /* Beware: If we don't have enough bytes left to disassemble the + * following insn, fall through to byte mode. + */ + if (D->Size <= RemainingBytes) { + D->Handler (D); + PC += D->Size; + break; + } + /* FALLTHROUGH */ + case atByteTab: ByteTable (); break;