Blame SOURCES/0006-snd_worker-fix-memory-leak-of-PlaybackChannel.patch

e2c81d
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4c08dd
From: Yonit Halperin <yhalperi@redhat.com>
4c08dd
Date: Thu, 25 Jul 2013 14:49:33 -0400
20333d
Subject: [PATCH] snd_worker: fix memory leak of PlaybackChannel
4c08dd
4c08dd
When the sequence of calls bellow occurs, the PlaybackChannel
4c08dd
is not released (snd_channel_put is not called for the
4c08dd
samples that refer to the channel).
4c08dd
4c08dd
    spice_server_playback_get_buffer
4c08dd
    snd_channel_disconnect
4c08dd
    spice_server_playback_put_samples
4c08dd
---
4c08dd
 server/snd_worker.c | 9 ++++-----
4c08dd
 1 file changed, 4 insertions(+), 5 deletions(-)
4c08dd
4c08dd
diff --git a/server/snd_worker.c b/server/snd_worker.c
4c08dd
index d6ec47a..849f002 100644
4c08dd
--- a/server/snd_worker.c
4c08dd
+++ b/server/snd_worker.c
4c08dd
@@ -1097,14 +1097,13 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
4c08dd
     PlaybackChannel *playback_channel;
4c08dd
     AudioFrame *frame;
4c08dd
 
4c08dd
-    if (!sin->st->worker.connection) {
4c08dd
-        return;
4c08dd
-    }
4c08dd
-
4c08dd
     frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
4c08dd
     playback_channel = frame->channel;
4c08dd
-    if (!snd_channel_put(&playback_channel->base) || !playback_channel->base.worker->connection) {
4c08dd
+    spice_assert(playback_channel);
4c08dd
+    if (!snd_channel_put(&playback_channel->base) ||
4c08dd
+        sin->st->worker.connection != &playback_channel->base) {
4c08dd
         /* lost last reference, channel has been destroyed previously */
4c08dd
+        spice_info("audio samples belong to a disconnected channel");
4c08dd
         return;
4c08dd
     }
4c08dd
     spice_assert(playback_channel->base.active);