Commit 76d4c63f authored by Alicia Boya García's avatar Alicia Boya García
Browse files

qtdemux: Use safer clearing functions in dispose()

In theory, `dispose()` functions should be idempotent and should be
prepared not to crash or cause a double-free if an unref done from
inside caused a recursive call to `dispose()` of the same object.

This patch modifies the `dispose()` method to honor these constraints.

Since the double `dispose()` call won't actually occur in qtdemux (there
is no cycle detection mechanism that could invoke it to work that way),
this is more of a code cleanup than a user-facing problem fix.
parent 451fc5c1
Pipeline #97090 passed with stages
in 106 minutes and 25 seconds
...@@ -691,6 +691,11 @@ gst_qtdemux_finalize (GObject * object) ...@@ -691,6 +691,11 @@ gst_qtdemux_finalize (GObject * object)
GstQTDemux *qtdemux = GST_QTDEMUX (object); GstQTDemux *qtdemux = GST_QTDEMUX (object);
g_free (qtdemux->redirect_location); g_free (qtdemux->redirect_location);
g_free (qtdemux->cenc_aux_info_sizes);
g_mutex_clear (&qtdemux->expose_lock);
g_ptr_array_free (qtdemux->active_streams, TRUE);
g_ptr_array_free (qtdemux->old_streams, TRUE);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
...@@ -699,23 +704,17 @@ static void ...@@ -699,23 +704,17 @@ static void
gst_qtdemux_dispose (GObject * object) gst_qtdemux_dispose (GObject * object)
{ {
GstQTDemux *qtdemux = GST_QTDEMUX (object); GstQTDemux *qtdemux = GST_QTDEMUX (object);
GstEvent *event;
if (qtdemux->adapter) { /* In theory, the dispose function should work even if an unref done here immediately calls it again. */
g_object_unref (G_OBJECT (qtdemux->adapter));
qtdemux->adapter = NULL;
gst_tag_list_unref (qtdemux->tag_list);
gst_flow_combiner_free (qtdemux->flowcombiner);
g_queue_foreach (&qtdemux->protection_event_queue, (GFunc) gst_event_unref,
g_queue_clear (&qtdemux->protection_event_queue);
g_free (qtdemux->cenc_aux_info_sizes); g_clear_object (&qtdemux->adapter);
qtdemux->cenc_aux_info_sizes = NULL; gst_clear_tag_list (&qtdemux->tag_list);
g_mutex_clear (&qtdemux->expose_lock); g_clear_pointer (&qtdemux->flowcombiner, gst_flow_combiner_unref);
g_ptr_array_free (qtdemux->active_streams, TRUE); while ((event =
g_ptr_array_free (qtdemux->old_streams, TRUE); GST_EVENT (g_queue_pop_head (&qtdemux->protection_event_queue))))
gst_event_unref (event);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment