[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] vnc: severe memory leak caused by broken palette_destroy()

From: Ulrich Obergfell
Subject: [Qemu-devel] vnc: severe memory leak caused by broken palette_destroy() function
Date: Mon, 21 Mar 2011 07:52:19 -0400 (EDT)

The following commit breaks the code of the function palette_destroy().


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

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) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]