From 0cc6d16c94d0e5ab09167b3a8d03ed0531c8f795 Mon Sep 17 00:00:00 2001 From: Heinrich Fink Date: Thu, 30 Jul 2015 23:31:21 +0200 Subject: [PATCH] applemedia/avsample: Fix racy cleanup of CA layer The block that is dispatched async to the main thread assumed the wrapping GstAvSampleVideoSink to be alive. However, at the time of the block execution the GstObject instance that is deferenced to access the CA layer might already be freed, which caused occasional crashes. Instead, we now only pass the CoreAnimation layer that needs to be released to the block. We use __block to make sure the block is not increasing the refcount of the CA layer again on its own. https://bugzilla.gnome.org/show_bug.cgi?id=753081 --- sys/applemedia/avsamplevideosink.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/applemedia/avsamplevideosink.m b/sys/applemedia/avsamplevideosink.m index 08f7e13f49..610b40a745 100644 --- a/sys/applemedia/avsamplevideosink.m +++ b/sys/applemedia/avsamplevideosink.m @@ -157,10 +157,11 @@ static void gst_av_sample_video_sink_finalize (GObject * object) { GstAVSampleVideoSink *av_sink = GST_AV_SAMPLE_VIDEO_SINK (object); + __block AVSampleBufferDisplayLayer *layer = av_sink->layer; - if (av_sink->layer) { + if (layer) { dispatch_async (dispatch_get_main_queue (), ^{ - [av_sink->layer release]; + [layer release]; }); } -- 2.34.1