spice: fix memory leak
commita41642708a5d1cbe8ad966227bbee1ed5eb421ad
authorGonglei <arei.gonglei@huawei.com>
Fri, 5 Dec 2014 08:30:10 +0000 (5 16:30 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 16 Dec 2014 13:15:29 +0000 (16 14:15 +0100)
treee9a947c3f26b8e431735a5de3586b22dd8206ade
parente0883e2de0ef36f254acc274e80ddeac13a2a8f6
spice: fix memory leak

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