[PATCH spice-server 6/8] snd_worker: fix memory leak of PlaybackChannel

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

 



When the sequence of calls bellow occurs, the PlaybackChannel
is not released (snd_channel_put is not called for the
samples that refer to the channel).

    spice_server_playback_get_buffer
    snd_channel_disconnect
    spice_server_playback_put_samples
---
 server/snd_worker.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/server/snd_worker.c b/server/snd_worker.c
index d6ec47a..849f002 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -1097,14 +1097,13 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
     PlaybackChannel *playback_channel;
     AudioFrame *frame;
 
-    if (!sin->st->worker.connection) {
-        return;
-    }
-
     frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
     playback_channel = frame->channel;
-    if (!snd_channel_put(&playback_channel->base) || !playback_channel->base.worker->connection) {
+    spice_assert(playback_channel);
+    if (!snd_channel_put(&playback_channel->base) ||
+        sin->st->worker.connection != &playback_channel->base) {
         /* lost last reference, channel has been destroyed previously */
+        spice_info("audio samples belong to a disconnected channel");
         return;
     }
     spice_assert(playback_channel->base.active);
-- 
1.8.1.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]