[vbox-dev] [PATCH] VBoxManage snapshot restorecurrent segfault

Daniel Wyatt daniel.wyatt at gmail.com
Wed Oct 21 07:26:54 GMT 2015


For machines that do not have any snapshots, these commands will currently
cause a crash in VBoxManage:

VBoxManage snapshot "machine_with_no_snapshots" restorecurrent
VBoxManage snapshot "machine_with_no_snapshots" edit --current --name
'new_name'

See the attached patch for a fix.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20151021/2a55cec3/attachment.html>
-------------- next part --------------
Index: VBoxManageSnapshot.cpp
===================================================================
--- VBoxManageSnapshot.cpp	(revision 58256)
+++ VBoxManageSnapshot.cpp	(working copy)
@@ -501,6 +501,11 @@
             if (fRestoreCurrent)
             {
                 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
+                if (pSnapshot.isNull())
+                {
+                    RTPrintf("This machine does not have any snapshots\n");
+                    return RTEXITCODE_FAILURE;
+                }
             }
             else
             {
@@ -541,6 +546,11 @@
                 || !strcmp(a->argv[2], "-current"))
             {
                 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
+                if (pSnapshot.isNull())
+                {
+                    RTPrintf("This machine does not have any snapshots\n");
+                    return RTEXITCODE_FAILURE;
+                }
             }
             else
             {


More information about the vbox-dev mailing list