1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-01 14:29:51 +00:00

Adds a quick protection against sector ID buffer overrun.

This commit is contained in:
Thomas Harte 2020-11-16 19:52:42 -05:00
parent 9a55eb56ea
commit e41faeb557

View File

@ -202,7 +202,7 @@ std::shared_ptr<::Storage::Disk::Track> MacintoshIMG::get_track_at_position(::St
int destination = 0;
for(int c = 0; c < included_sectors.length; ++c) {
// Deal with collisions by finding the next non-colliding spot.
while(source_sectors[destination] != 0xff) ++destination;
while(source_sectors[destination] != 0xff) destination = (destination + 1) % included_sectors.length;
source_sectors[destination] = uint8_t(c);
destination = (destination + (format_ & 0x1f)) % included_sectors.length;
}