From 5518dd69c7f1d28aab313f7c102090cc46547392 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 13 May 2012 23:11:20 +0100 Subject: [PATCH] oggdemux: fix potential crash in SEEKING query handler Take chain lock when accessing chains. Fall back gracefully when there's no current chain Hopefully fixes crash when seeking in Jamendo or Magnatune streams in Amarok. https://bugzilla.gnome.org/show_bug.cgi?id=675609 --- ext/ogg/gstoggdemux.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 0c1a9bb..cb8c2f7 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -301,11 +301,23 @@ gst_ogg_pad_src_query (GstPad * pad, GstObject * parent, GstQuery * query) gboolean seekable = FALSE; gint64 stop = -1; + GST_CHAIN_LOCK (ogg); if (ogg->pullmode) { seekable = TRUE; stop = ogg->total_time; } else if (ogg->push_disable_seeking) { seekable = FALSE; + } else if (ogg->current_chain == NULL) { + GstQuery *squery; + + /* assume we can seek if upstream is seekable in BYTES format */ + GST_LOG_OBJECT (ogg, "no current chain, check upstream seekability"); + squery = gst_query_new_seeking (GST_FORMAT_BYTES); + if (gst_pad_peer_query (ogg->sinkpad, squery)) + gst_query_parse_seeking (squery, NULL, &seekable, NULL, NULL); + else + seekable = FALSE; + gst_query_unref (squery); } else if (ogg->current_chain->streams->len) { gint i; @@ -334,6 +346,7 @@ gst_ogg_pad_src_query (GstPad * pad, GstObject * parent, GstQuery * query) } gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, 0, stop); + GST_CHAIN_UNLOCK (ogg); } else { res = FALSE; } -- 2.7.4