]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
spice: fix memory leak
authorGonglei <arei.gonglei@huawei.com>
Fri, 5 Dec 2014 08:30:10 +0000 (16:30 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 16 Dec 2014 13:15:29 +0000 (14:15 +0100)
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 <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/spice-core.c

index 497670c4d5e25a617221af043d83e0676c8a3f2e..fe705c1ae2d2273e7231e99c58334b96f7c667f5 100644 (file)
@@ -385,10 +385,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));