]> xenbits.xensource.com Git - libvirt.git/commitdiff
vbox_temp: Resolve Coverity warnings
authorJohn Ferlan <jferlan@redhat.com>
Wed, 11 Jun 2014 13:14:50 +0000 (09:14 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 12 Jun 2014 09:36:37 +0000 (05:36 -0400)
Clean up code to resolve Coverity RESOURCE_LEAK's from commit id's
'632b9600' and 'b739f807'.

src/vbox/vbox_tmpl.c

index da9b2b740d167473033f8ab6b404ae0b675e807a..1ed27290708fd1b2ba8caf332ed2fe4012a7951c 100644 (file)
@@ -6267,6 +6267,11 @@ vboxSnapshotRedefine(virDomainPtr dom,
              */
             parentUuid = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
                                                       realReadOnlyDisksPath[it]);
+            if (parentUuid == NULL) {
+                VIR_FREE(readWriteDisk);
+                goto cleanup;
+            }
+
             if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readWriteDisk,
                                            snapshotMachineDesc->mediaRegistry,
                                            parentUuid) < 0) {
@@ -8576,14 +8581,17 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("Unable to get medium uuid, rc=%08x"),
                                    (unsigned)rc);
+                    VIR_FREE(disk);
                     goto cleanup;
                 }
                 VBOX_UTF16_TO_UTF8(uuidUtf16, &uuid);
                 disk->uuid = uuid;
                 VBOX_UTF16_FREE(uuidUtf16);
 
-                if (VIR_STRDUP(disk->location, newLocationUtf8) < 0)
+                if (VIR_STRDUP(disk->location, newLocationUtf8) < 0) {
+                    VIR_FREE(disk);
                     goto cleanup;
+                }
 
                 rc = newMedium->vtbl->GetFormat(newMedium, &formatUtf16);
                 VBOX_UTF16_TO_UTF8(formatUtf16, &format);