Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 30938)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 30939)
@@ -6049,5 +6049,7 @@
     else
         // caller wants no automatic detachment: then fail if there are any
-        if (mMediaData->mAttachments.size())
+        if (    !mMediaData.isNull()      // can be NULL if machine is inaccessible
+             && mMediaData->mAttachments.size()
+           )
             return setError(VBOX_E_INVALID_OBJECT_STATE,
                             tr("Cannot unregister the machine '%ls' because it has %d media attachments"),
