Skip to content

Commit 1f09b8c

Browse files
Maneesha Pkaruturi
authored andcommitted
Fixed Coverity issue "Dereference null return value"
added a not null check and a CloudRuntimeException in case of null Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com> This closes apache#617
1 parent d8f37c5 commit 1f09b8c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtBackupSnapshotCommandWrapper.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ public Answer execute(final BackupSnapshotCommand command, final LibvirtComputin
171171
final String snapshot = snapshotXML.format(args);
172172
s_logger.debug(snapshot);
173173
final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
174-
snap.delete(0);
174+
if (snap != null) {
175+
snap.delete(0);
176+
} else {
177+
throw new CloudRuntimeException("Unable to find vm snapshot with name -" + snapshotName);
178+
}
175179

176180
/*
177181
* libvirt on RHEL6 doesn't handle resume event emitted from
@@ -203,4 +207,4 @@ public Answer execute(final BackupSnapshotCommand command, final LibvirtComputin
203207
}
204208
return new BackupSnapshotAnswer(command, true, null, snapshotRelPath + File.separator + snapshotName, true);
205209
}
206-
}
210+
}

0 commit comments

Comments
 (0)