1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-27 15:29:34 +00:00

Avoid going out of bounds below.

This commit is contained in:
Thomas Harte 2024-12-16 22:11:49 -05:00
parent 9d5c10d440
commit 2240ada5db

View File

@ -108,7 +108,7 @@ std::optional<BASICAnalysis> analyse(const File &file) {
while(true) {
// Analysis has failed if there isn't at least one complete BASIC line from here.
// Fall back on guessing the start address as a machine code entrypoint.
if(size_t(line_address - file.starting_address) + 5 >= file.data.size()) {
if(size_t(line_address - file.starting_address) + 5 >= file.data.size() || line_address < file.starting_address) {
analysis.machine_code_addresses.push_back(file.starting_address);
break;
}