flvdemux: Fix tests warning from setting a NULL index
authorJan Schmidt <thaytan@noraisin.net>
Mon, 31 Aug 2009 10:32:39 +0000 (11:32 +0100)
committerJan Schmidt <thaytan@noraisin.net>
Mon, 31 Aug 2009 11:10:05 +0000 (12:10 +0100)
Setting a null index in the tests was causing warnings by unreffing
NULL pointers. This is a bug exposed by a recent change in core, it
seems.

gst/flv/gstflvdemux.c

index 59a12d0..1f70002 100644 (file)
@@ -1183,11 +1183,14 @@ gst_flv_demux_set_index (GstElement * element, GstIndex * index)
   GST_OBJECT_LOCK (demux);
   if (demux->index)
     gst_object_unref (demux->index);
-  demux->index = gst_object_ref (index);
-  GST_OBJECT_UNLOCK (demux);
+  if (index) {
+    demux->index = gst_object_ref (index);
+    gst_index_get_writer_id (index, GST_OBJECT (element), &demux->index_id);
+    demux->own_index = FALSE;
+  } else
+    demux->index = NULL;
 
-  gst_index_get_writer_id (index, GST_OBJECT (element), &demux->index_id);
-  demux->own_index = FALSE;
+  GST_OBJECT_UNLOCK (demux);
 }
 
 static GstIndex *