summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-11-17 16:43:04 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-11-17 16:43:04 +0000
commite5983c621eb52ed93cc1949a70969785f0e2fd32 (patch)
treeae4d23c3f01001fdf4ae1b2d780a5d2f5c6ffd8c
parent3e973e3507ce9dfd6d5b62130451348c5e9365a4 (diff)
downloadVirtualBox-svn-e5983c621eb52ed93cc1949a70969785f0e2fd32.tar.gz
Main/SnapshotImpl: Check if a given (current) snapshot object is valid, or bail out if not.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@97598 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r--src/VBox/Main/src-server/SnapshotImpl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/VBox/Main/src-server/SnapshotImpl.cpp b/src/VBox/Main/src-server/SnapshotImpl.cpp
index 0320b49812a..e3cac167ea2 100644
--- a/src/VBox/Main/src-server/SnapshotImpl.cpp
+++ b/src/VBox/Main/src-server/SnapshotImpl.cpp
@@ -2231,6 +2231,16 @@ HRESULT SessionMachine::restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
if (FAILED(rc))
return rc;
+ /* We need to explicitly check if the given snapshot is valid and bail out if not. */
+ if (aSnapshot.isNull())
+ {
+ if (aSnapshot == mData->mCurrentSnapshot)
+ return setError(VBOX_E_OBJECT_NOT_FOUND,
+ tr("This VM does not have any current snapshot"));
+
+ return setError(E_INVALIDARG, tr("The given snapshot is invalid"));
+ }
+
ISnapshot* iSnapshot = aSnapshot;
ComObjPtr<Snapshot> pSnapshot(static_cast<Snapshot*>(iSnapshot));
ComObjPtr<SnapshotMachine> pSnapMachine = pSnapshot->i_getSnapshotMachine();