bugfix: When the DOS kernel shuts down, make sure the Drives[] array is

zeroed as well. Prior to this fix, mounting drive c: then booting a
guest OS would leave behind stale (invalid) pointers in the Drives[]
array once the BOOT program shut the DOS kernel down. This wouldn't
cause any problems until you attempted to use the Disk Swap hotkey, at
which point, DOSBox would crash.
This commit is contained in:
Jonathan Campbell
2014-04-21 22:22:11 -07:00
parent 4c6d5991f8
commit 06808abbba
3 changed files with 6 additions and 3 deletions

View File

@@ -1727,7 +1727,10 @@ public:
dos.version.minor=0;
}
~DOS(){
for (Bit16u i=0;i<DOS_DRIVES;i++) delete Drives[i];
for (Bit16u i=0;i<DOS_DRIVES;i++) {
delete Drives[i];
Drives[i] = NULL;
}
delete [] Files;
}
};

View File

@@ -42,7 +42,7 @@
Bitu DOS_FILES = 127;
DOS_File ** Files;
DOS_Drive * Drives[DOS_DRIVES];
DOS_Drive * Drives[DOS_DRIVES] = {NULL};
Bit8u DOS_GetDefaultDrive(void) {
// return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDrive();

View File

@@ -148,7 +148,7 @@ void swapInNextDisk(bool pressed) {
/* Hack/feature: rescan all disks as well */
LOG_MSG("Diskcaching reset for normal mounted drives.");
for(Bitu i=0;i<DOS_DRIVES;i++) {
if (Drives[i]) {
if (Drives[i] != NULL) {
Drives[i]->EmptyCache();
Drives[i]->MediaChange();
}