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
This commit is contained in:
Alex Ashley 2014-02-25 11:45:46 +00:00 committed by Sebastian Dröge
parent 9cc52bd874
commit b7ef52c515

View file

@ -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;
}