hlsdemux: don't try to access non-existant iframe variant
authorMichael Olbrich <m.olbrich@pengutronix.de>
Fri, 28 Oct 2016 08:05:20 +0000 (10:05 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 31 Oct 2016 12:03:06 +0000 (14:03 +0200)
If the playlist does not contain any iframe variants then
demux->master->iframe_variants is NULL. If the previous variant is an
iframe variant then there is at least one iframe variant and
demux->master->iframe_variants->data can be safely used.

https://bugzilla.gnome.org/show_bug.cgi?id=773635

ext/hls/gsthlsdemux.c

index a4eaacd..bb91f30 100644 (file)
@@ -1574,14 +1574,16 @@ retry_failover_protection:
     GST_M3U8_CLIENT_UNLOCK (demux->client);
     gst_hls_demux_set_current_variant (demux, previous_variant);
     /*  Try a lower bitrate (or stop if we just tried the lowest) */
-    lowest_variant = demux->master->variants->data;
-    lowest_ivariant = demux->master->iframe_variants->data;
-    if (previous_variant->iframe && new_bandwidth == lowest_ivariant->bandwidth)
-      return FALSE;
-    if (!previous_variant->iframe && new_bandwidth == lowest_variant->bandwidth)
-      return FALSE;
-    else
-      return gst_hls_demux_change_playlist (demux, new_bandwidth - 1, changed);
+    if (previous_variant->iframe) {
+      lowest_ivariant = demux->master->iframe_variants->data;
+      if (new_bandwidth == lowest_ivariant->bandwidth)
+        return FALSE;
+    } else {
+      lowest_variant = demux->master->variants->data;
+      if (new_bandwidth == lowest_variant->bandwidth)
+        return FALSE;
+    }
+    return gst_hls_demux_change_playlist (demux, new_bandwidth - 1, changed);
   }
 
   return TRUE;