summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2014-10-22 16:48:14 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-10-23 13:49:50 +0200
commit6729c341120f7111c5b91acde89601e5cb23eb83 (patch)
treee92e3bfd62b56225899380d269d8412f8fb99334
parentaf733ed71f118e11c39d0aeb5c0ed12f015b9ad8 (diff)
Fix SndCodec leak in playback_handle_start()
An audio SpiceChannel can get several times the 'start' message during its lifetime. If received multiple times (for example when rebooting a VM), this would lead to a SndCodec leak as reported by valgrind: ==7749== 27,036 (48 direct, 26,988 indirect) bytes in 1 blocks are definitely lost in loss record 11,418 of 11,440 ==7749== at 0x4A08946: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==7749== by 0x5772A9A: spice_malloc0 (mem.c:109) ==7749== by 0x5772D42: spice_malloc0_n (mem.c:173) ==7749== by 0x57FB3E2: snd_codec_create (snd_codec.c:267) ==7749== by 0x573774C: playback_handle_start (channel-playback.c:380) ==7749== by 0x5721E44: spice_channel_handle_msg (spice-channel.c:2859) ==7749== by 0x571ECB3: spice_channel_recv_msg (spice-channel.c:1877) ==7749== by 0x571F402: spice_channel_iterate_read (spice-channel.c:2114) ==7749== by 0x571F614: spice_channel_iterate (spice-channel.c:2152) ==7749== by 0x5720411: spice_channel_coroutine (spice-channel.c:2429) ==7749== by 0x575CD3A: coroutine_trampoline (coroutine_ucontext.c:63) ==7749== by 0x575C9F4: continuation_trampoline (continuation.c:55) ==7749== by 0x3898E47FEF: ??? (in /usr/lib64/libc-2.20.so) ==7749== by 0xAED547666C92C2FF: ??? ==7749== by 0xFFEFFF92F: ???
-rw-r--r--gtk/channel-playback.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
index e5b9658..40e01ba 100644
--- a/gtk/channel-playback.c
+++ b/gtk/channel-playback.c
@@ -375,6 +375,7 @@ static void playback_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
c->codec = NULL;
if (c->mode != SPICE_AUDIO_DATA_MODE_RAW) {
+ snd_codec_destroy(&c->codec);
if (snd_codec_create(&c->codec, c->mode, start->frequency, SND_CODEC_DECODE) != SND_CODEC_OK) {
g_warning("create decoder failed");
return;