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

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@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

On Thu, May 22, 2008 at 09:37:22PM +0200, Jim Meyering wrote:
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.
I noticed that no one had commented on this, but the code looks fine, so +1. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

"Richard W.M. Jones" <rjones@redhat.com> wrote:
On Thu, May 22, 2008 at 09:37:22PM +0200, Jim Meyering wrote:
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.
I noticed that no one had commented on this, but the code looks fine, so +1.
Hi Rich, Thanks. Not long after I wrote that I heard that Dan Berrange had fixed it (identically) in one of his patches. Dan, I'll be happy to commit it, if you'd like. I would have already done it, but figured it might cause a conflict with the other changes in Dan's change set.
participants (2)
-
Jim Meyering
-
Richard W.M. Jones