From b7ef52c515d9de53a08c450eef84492ba79796b3 Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Tue, 25 Feb 2014 11:45:46 +0000 Subject: [PATCH] hlsdemux: Segfaults if playlist has no media files hlsdemux causes a null pointer dereference if the media playlist does not contain any media files. The gst_m3u8_client_get_duration function assumes that demux->client->current->files is valid when computing duration. gst_m3u8_client_update needed to be modified to check for the case of downloading an M3U8 file that doesn't contain any media files, and returning an error to gsthlsdemux.c This bug can be reproduced by creating a master m3u8 file that contains one media playlist that points back to the master m3u8 file. For example create a file called bug725134.m3u8: #EXTM3U #EXT-X-VERSION:4 #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1251135, CODECS="avc1.42001f mp4a.40.2", RESOLUTION=640x352 bug725134.m3u8 https://bugzilla.gnome.org/show_bug.cgi?id=725134 --- ext/hls/m3u8.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index a9520efedd..52fab5b547 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -548,6 +548,11 @@ gst_m3u8_client_update (GstM3U8Client * self, gchar * data) goto out; } + if (self->current && !self->current->files) { + GST_ERROR ("Invalid media playlist, it does not contain any media files"); + goto out; + } + /* select the first playlist, for now */ if (!self->current) { if (self->main->lists) { @@ -672,8 +677,8 @@ gst_m3u8_client_get_duration (GstM3U8Client * client) GST_M3U8_CLIENT_UNLOCK (client); return GST_CLOCK_TIME_NONE; } - - g_list_foreach (client->current->files, (GFunc) _sum_duration, &duration); + if (client->current && client->current->files) + g_list_foreach (client->current->files, (GFunc) _sum_duration, &duration); GST_M3U8_CLIENT_UNLOCK (client); return duration; }