fix crasher when accessing empty drive

This commit is contained in:
Jorj Bauer 2020-07-02 22:01:01 -04:00
parent 48ef6a4dea
commit 36ce493c1e

View File

@ -461,7 +461,11 @@ void DiskII::setPhase(uint8_t phase)
}
if (curHalfTrack[selectedDisk] != prevHalfTrack) {
if (disk[selectedDisk]) {
curWozTrack[selectedDisk] = disk[selectedDisk]->dataTrackNumberForQuarterTrack(curHalfTrack[selectedDisk]*2);
} else {
curWozTrack[selectedDisk] = 0;
}
}
}
@ -547,7 +551,11 @@ void DiskII::insertDisk(int8_t driveNum, const char *filename, bool drawIt)
disk[driveNum] = new WozSerializer();
// intentionally 'false' (see above call to readFile)
disk[driveNum]->readFile(filename, false, T_AUTO); // FIXME error checking
if (!disk[driveNum]->readFile(filename, false, T_AUTO)) {
delete disk[driveNum];
disk[driveNum] = NULL;
return;
}
curWozTrack[driveNum] = disk[driveNum]->dataTrackNumberForQuarterTrack(curHalfTrack[driveNum]*2);