]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorTextAttachDrive: avoid two leaks
authorJim Meyering <meyering@redhat.com>
Mon, 25 Jan 2010 19:19:01 +0000 (20:19 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 25 Jan 2010 21:06:47 +0000 (22:06 +0100)
* src/qemu/qemu_monitor_text.c (qemuMonitorTextAttachDrive): Most other
failures in this function would "goto cleanup", but one mistakenly
returned directly, skipping the cleanup and resulting in a leak.
In addition, iterating the "try_command" loop would clobber, and
thus leak, the "cmd" allocated on the first iteration,
so be careful to free it in addition to "reply" beforehand.

src/qemu/qemu_monitor_text.c

index ce5349bd712f4b0ed50a874c08d0fa155a154784..380bcdc1168eaaae3e2b89bd472a54ef83a82f6c 100644 (file)
@@ -1881,13 +1881,13 @@ try_command:
     if (qemudParseDriveAddReply(reply, driveAddr) < 0) {
         if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
             VIR_FREE(reply);
+            VIR_FREE(cmd);
             tryOldSyntax = 1;
             goto try_command;
         }
         qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
                           _("adding %s disk failed: %s"), drivestr, reply);
-        VIR_FREE(reply);
-        return -1;
+        goto cleanup;
     }
 
     ret = 0;