qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2] spice: fix memory leak


From: arei.gonglei
Subject: [Qemu-devel] [PATCH v2] spice: fix memory leak
Date: Fri, 5 Dec 2014 16:30:10 +0800

From: Gonglei <address@hidden>

If errors happen for middle items of channel_list,
qmp_query_spice_channels() returns NULL, and the variable
cur_item going out of scope leaks the storage it points to.

The flag is a compatibility thing for older spice-server
versions. Meanwhile our minimum spice version requirement is
new enough that we should never ever see this error, and if we
do something went very seriously wrong. Let's using assert()
instead of returning NULL to avoid a memory leak.

Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Gonglei <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
v2: 
 - using assert() instead of returning NULL. (Gerd)
 - fix some typos. (Eric)
 - add Eric's R-by tag, hope Eric has no objection
   because of changes of v2. :)
---
 ui/spice-core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6467fa4..1100f8e 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -386,10 +386,7 @@ static SpiceChannelList *qmp_query_spice_channels(void)
         struct sockaddr *paddr;
         socklen_t plen;
 
-        if (!(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT)) {
-            error_report("invalid channel event");
-            return NULL;
-        }
+        assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT);
 
         chan = g_malloc0(sizeof(*chan));
         chan->value = g_malloc0(sizeof(*chan->value));
-- 
1.7.12.4





reply via email to

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