[libvirt] [PATCH] qemu_monitor_json.c: avoid an unconditional leak

Jim Meyering jim at meyering.net
Wed Jan 27 09:28:43 UTC 2010


Calling virJSONValueFree does not free the memory allocated via this:

    cmd = qemuMonitorJSONMakeCommand("drive_add",
                                     "s:pci_addr", dev,
                                     "s:opts", drivestr,
                                     NULL);

so I added the VIR_FREE:

>From 1d272e070b66fc16e2fcc23002879ee268a58a5f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Wed, 27 Jan 2010 09:58:12 +0100
Subject: [PATCH] qemu_monitor_json.c: avoid an unconditional leak

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAttachDrive):
Don't leak the buffer behind a virJSONValuePtr.
---
 src/qemu/qemu_monitor_json.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8e88c7e..0f970bb 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1773,6 +1773,7 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
         ret = -1;

     virJSONValueFree(cmd);
+    VIR_FREE(cmd);
     virJSONValueFree(reply);
     return ret;
 }
--
1.7.0.rc0.140.gfbe7




More information about the libvir-list mailing list