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 #617
This commit is contained in:
Maneesha P 2015-07-23 00:45:00 +05:30 committed by Rajani Karuturi
parent d8f37c5e17
commit 1f09b8c3bf
1 changed files with 6 additions and 2 deletions

View File

@ -171,7 +171,11 @@ public final class LibvirtBackupSnapshotCommandWrapper extends CommandWrapper<Ba
final String snapshot = snapshotXML.format(args);
s_logger.debug(snapshot);
final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
snap.delete(0);
if (snap != null) {
snap.delete(0);
} else {
throw new CloudRuntimeException("Unable to find vm snapshot with name -" + snapshotName);
}
/*
* libvirt on RHEL6 doesn't handle resume event emitted from
@ -203,4 +207,4 @@ public final class LibvirtBackupSnapshotCommandWrapper extends CommandWrapper<Ba
}
return new BackupSnapshotAnswer(command, true, null, snapshotRelPath + File.separator + snapshotName, true);
}
}
}