From: Ulrich Obergfell <uobergfe@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] vnc: severe memory leak caused by broken palette_destroy() function
Date: Mon, 21 Mar 2011 07:52:19 -0400 (EDT) [thread overview]
Message-ID: <732683382.437646.1300708339597.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <649134907.437547.1300708075324.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com>
The following commit breaks the code of the function palette_destroy().
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268
The broken code causes a severe memory leak of 'VncPalette' structures
because it never frees anything:
70 void palette_destroy(VncPalette *palette)
71 {
72 if (palette == NULL) {
73 qemu_free(palette);
74 }
75 }
Calling qemu_free() unconditionally could be considered. However,
the original code (prior to the aforementioned commit) returned
immediately if 'palette' was NULL. In order to be closer to the
original code, the proposed patch corrects the 'if' statement.
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
diff -up ./ui/vnc-palette.c.orig0 ./ui/vnc-palette.c
--- ./ui/vnc-palette.c.orig0 2011-03-15 03:53:22.000000000 +0100
+++ ./ui/vnc-palette.c 2011-03-20 11:52:57.257560295 +0100
@@ -69,7 +69,7 @@ void palette_init(VncPalette *palette, s
void palette_destroy(VncPalette *palette)
{
- if (palette == NULL) {
+ if (palette) {
qemu_free(palette);
}
}
next parent reply other threads:[~2011-03-21 11:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <649134907.437547.1300708075324.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com>
2011-03-21 11:52 ` Ulrich Obergfell [this message]
2011-03-21 12:33 ` [Qemu-devel] vnc: severe memory leak caused by broken palette_destroy() function Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=732683382.437646.1300708339597.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com \
--to=uobergfe@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).