[SCM] libgroove/upstream: fix race condition segfault when attaching a sink

andrewrk-guest at users.alioth.debian.org andrewrk-guest at users.alioth.debian.org
Sat May 31 19:00:02 UTC 2014


The following commit has been merged in the upstream branch:
commit e645ad3bf4ec8a167af0d826fabafdf6364ffeff
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Sat May 31 11:12:10 2014 -0700

    fix race condition segfault when attaching a sink

diff --git a/groove/playlist.c b/groove/playlist.c
index fd54376..d15815a 100644
--- a/groove/playlist.c
+++ b/groove/playlist.c
@@ -873,12 +873,16 @@ int groove_sink_attach(struct GrooveSink *sink, struct GroovePlaylist *playlist)
     // add the sink to the entry that matches its audio format
     struct GroovePlaylistPrivate *p = (struct GroovePlaylistPrivate *) playlist;
 
+    // must do this above add_sink_to_map to avid race condition
+    sink->playlist = playlist;
+
     pthread_mutex_lock(&p->decode_head_mutex);
     int err = add_sink_to_map(playlist, sink);
     pthread_cond_signal(&p->sink_drain_cond);
     pthread_mutex_unlock(&p->decode_head_mutex);
 
     if (err < 0) {
+        sink->playlist = NULL;
         av_log(NULL, AV_LOG_ERROR, "unable to attach device: out of memory\n");
         return err;
     }
@@ -886,8 +890,6 @@ int groove_sink_attach(struct GrooveSink *sink, struct GroovePlaylist *playlist)
     // in case we've called abort on the queue, reset
     groove_queue_reset(s->audioq);
 
-    sink->playlist = playlist;
-
     return 0;
 }
 

-- 
libgroove packaging



More information about the pkg-multimedia-commits mailing list