From 5c6354e025716982bccfa06d3d496eecf52970cf Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Sat, 9 Jan 2021 11:30:19 -0500 Subject: [PATCH] fix disk behavior on bios reboot --- bios.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bios.cpp b/bios.cpp index 69d4837..181f39f 100644 --- a/bios.cpp +++ b/bios.cpp @@ -670,22 +670,27 @@ void BIOS::RebootAsIs() { // g_vm->Reset() will eject disks. We don't want to do that, so we need to // grab the inserted disk names; reset the VM; then restore the disks. - const char *disk6s1 = ((AppleVM *)g_vm)->DiskName(0); - const char *disk6s2 = ((AppleVM *)g_vm)->DiskName(1); - const char *hdd1 = ((AppleVM *)g_vm)->HDName(0); - const char *hdd2 = ((AppleVM *)g_vm)->HDName(1); - + char *disk6s1 = strdup(((AppleVM *)g_vm)->DiskName(0) ? ((AppleVM *)g_vm)->DiskName(0) : ""); + char *disk6s2 = strdup(((AppleVM *)g_vm)->DiskName(1) ? ((AppleVM *)g_vm)->DiskName(1) : ""); + char *hdd1 = strdup(((AppleVM *)g_vm)->HDName(0) ? ((AppleVM *)g_vm)->HDName(0) : ""); + char *hdd2 = strdup(((AppleVM *)g_vm)->HDName(1) ? ((AppleVM *)g_vm)->HDName(1) : ""); + g_vm->Reset(); g_cpu->Reset(); - if (disk6s1) + if (disk6s1[0]) ((AppleVM *)g_vm)->insertDisk(0, disk6s1); - if (disk6s2) + if (disk6s2[0]) ((AppleVM *)g_vm)->insertDisk(1, disk6s2); - if (hdd1) + if (hdd1[0]) ((AppleVM *)g_vm)->insertHD(0, hdd1); - if (hdd2) + if (hdd2[0]) ((AppleVM *)g_vm)->insertHD(2, hdd2); + + free(disk6s1); + free(disk6s2); + free(hdd1); + free(hdd2); } void BIOS::ColdReboot()