DSPDisassembler: Fix out-of-bounds read when the last word is an instruction with a large immediate

For instance, ending with 0x009e (which you can do with CW 0x009e) indicates a LRI $ac0.m instruction, but there is no immediate value to load, so before whatever garbage in memory existed after the end of the file was used.

The bounds-checking also previously assumed that IRAM or IROM was being used, both of which were exactly 0x1000 long.
This commit is contained in:
Pokechu22 committed 2022-06-14 12:22:06 -07:00
1 parent dc353ed84d
commit cad9801ded
4 files changed
+34 -13

No files matched your search

+3 -3
View File
@@ -78,9 +78,9 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
{
std::string line1, line2;
u16 pc = i;
disassembler.DisassembleOpcode(&code1[0], &pc, line1);
disassembler.DisassembleOpcode(code1, &pc, line1);
pc = i;
disassembler.DisassembleOpcode(&code2[0], &pc, line2);
disassembler.DisassembleOpcode(code2, &pc, line2);
fmt::print("!! {:04x} : {:04x} vs {:04x} - {} vs {}\n", i, code1[i], code2[i], line1,
line2);
}
@@ -93,7 +93,7 @@ bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2)
{
u16 pc = i;
std::string line;
disassembler.DisassembleOpcode(&longest[0], &pc, line);
disassembler.DisassembleOpcode(longest, &pc, line);
fmt::print("!! {}\n", line);
}
}