As with qemuSnapshotRedefine, make an extra reference in a temporary
autocleaned variable and use that instead of refing the definition after
it's stolen.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 5f256a77df..c5379d583e 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1750,11 +1750,12 @@ qemuSnapshotRedefine(virDomainObj *vm,
static virDomainSnapshotPtr
qemuSnapshotCreate(virDomainObj *vm,
virDomainPtr domain,
- virDomainSnapshotDef *snapdef,
+ virDomainSnapshotDef *snapdeftmp,
virQEMUDriver *driver,
virQEMUDriverConfig *cfg,
unsigned int flags)
{
+ g_autoptr(virDomainSnapshotDef) snapdef = virObjectRef(snapdeftmp);
g_autoptr(virDomainMomentObj) tmpsnap = NULL;
virDomainMomentObj *snap = NULL;
virDomainMomentObj *current = NULL;
@@ -1769,17 +1770,17 @@ qemuSnapshotCreate(virDomainObj *vm,
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) {
snap = tmpsnap = virDomainMomentObjNew();
snap->def = &snapdef->parent;
+ snapdef = NULL;
} else {
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
return NULL;
+ snapdef = NULL;
if ((current = virDomainSnapshotGetCurrent(vm->snapshots))) {
snap->def->parent_name = g_strdup(current->def->name);
}
}
- virObjectRef(snapdef);
-
/* actually do the snapshot */
if (virDomainObjIsActive(vm)) {
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY ||
--
2.31.1