From f2a7c28fc0556e9dc8811eb2e1db5570e47cc85f Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 8 Dec 2014 11:56:33 -0500 Subject: [PATCH] VBOX: Fix crash if DVD-ROM media had been ejected by some external event. Technically this shouldn't be happening, but something funky is going on with VirtualBox and we need to handle things that may cause a crash when cleaning up the VM. --- samples/vboxwrapper/vbox_mscom_impl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/samples/vboxwrapper/vbox_mscom_impl.cpp b/samples/vboxwrapper/vbox_mscom_impl.cpp index d977263161..9c6be6b0db 100644 --- a/samples/vboxwrapper/vbox_mscom_impl.cpp +++ b/samples/vboxwrapper/vbox_mscom_impl.cpp @@ -1144,7 +1144,11 @@ int VBOX_VM::deregister_vm(bool delete_media) { pMediumAttachment->get_Port(&lPort); pMediumAttachment->get_Medium(&pMedium); - mediums.push_back(CComPtr(pMedium)); + // If the device in question is a DVD/CD-ROM drive, the medium may have been ejected. + // If so, pMedium will be NULL. + if (pMedium) { + mediums.push_back(CComPtr(pMedium)); + } rc = pMachine->DetachDevice(strController, lPort, lDevice); CHECK_ERROR(rc);