From ee45291533677ceafc17601834126e61cb9853d3 Mon Sep 17 00:00:00 2001 From: joevt Date: Thu, 2 May 2024 05:37:08 -0700 Subject: [PATCH] superdrive: Make sure track remains in range. --- devices/floppy/superdrive.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devices/floppy/superdrive.cpp b/devices/floppy/superdrive.cpp index a9cbe90..5a0440b 100644 --- a/devices/floppy/superdrive.cpp +++ b/devices/floppy/superdrive.cpp @@ -66,6 +66,10 @@ void MacSuperDrive::command(uint8_t addr, uint8_t value) this->cur_track += this->step_dir; if (this->cur_track < 0) this->cur_track = 0; + else if (this->cur_track >= this->num_tracks) { + LOG_F(ERROR, "%s: track:%d is greater than max track:%d", this->get_name().c_str(), this->cur_track, this->num_tracks - 1); + this->cur_track = this->num_tracks - 1; + } this->track_zero = this->cur_track == 0; } break;