hlsdemux: Fix dereferencing of NULL pointer

On some live HLS streams, gst_hls_demux_switch_playlist causes
assertion failures because it tried to dereference a NULL fragment.
This is because g_queue_peek_tail sometimes was returning NULL and
this case was not being checked.

This patch does two things:
* move the g_queue_peek_tail inside the semaphore protection
* check if q_queue_peek_tail returns NULL

https://bugzilla.gnome.org/show_bug.cgi?id=708849
This commit is contained in:
Alex Ashley 2013-09-26 16:51:25 +01:00 committed by Sebastian Dröge
parent d7c7f54734
commit 0bdf13c36a

View file

@ -1213,11 +1213,12 @@ gst_hls_demux_switch_playlist (GstHLSDemux * demux)
GstClockTime diff;
gsize size;
gint bitrate;
GstFragment *fragment = g_queue_peek_tail (demux->queue);
GstFragment *fragment;
GstBuffer *buffer;
GST_M3U8_CLIENT_LOCK (demux->client);
if (!demux->client->main->lists) {
fragment = g_queue_peek_tail (demux->queue);
if (!demux->client->main->lists || !fragment) {
GST_M3U8_CLIENT_UNLOCK (demux->client);
return TRUE;
}