[libvirt] [PATCH] plug two sound-related leaks

Jim Meyering jim at meyering.net
Thu May 22 19:37:22 UTC 2008


This fixes the sole remaining leak exposed by "make check" vs. valgrind.
Actually it fixes two leaks, but the duplicate sound string one
isn't triggered by the tests.

>From 495abbe5adcb27187f4831a67f0821d62f36602e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Thu, 22 May 2008 21:34:19 +0200
Subject: [PATCH] plug two sound-related leaks

* src/qemu_conf.c (qemudFreeVMDef): Also free def->sounds.
(qemudParseXML): Avoid leak also for duplicate sound string.
---
 src/qemu_conf.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 15bf253..5c20023 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -215,6 +215,7 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
     struct qemud_vm_input_def *input = def->inputs;
     struct qemud_vm_chr_def *serial = def->serials;
     struct qemud_vm_chr_def *parallel = def->parallels;
+    struct qemud_vm_sound_def *sound = def->sounds;

     while (disk) {
         struct qemud_vm_disk_def *prev = disk;
@@ -241,6 +242,11 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
         parallel = parallel->next;
         free(prev);
     }
+    while (sound) {
+        struct qemud_vm_sound_def *prev = sound;
+        sound = sound->next;
+        free(prev);
+    }
     xmlFree(def->keymap);
     free(def);
 }
@@ -2187,8 +2193,10 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
                 }
                 check = check->next;
             }
-            if (collision)
+            if (collision) {
+                free(sound);
                 continue;
+            }

             def->nsounds++;
             sound->next = NULL;
--
1.5.5.1.249.g26848




More information about the libvir-list mailing list