diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-05-15 14:29:05 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-05-17 10:40:37 +0300 |
commit | 2e4c82d850981ac65b55a95922fda5f861bbbc57 (patch) | |
tree | fb6595e7e0d016c16fc8dcbaa1be1a065c83786c | |
parent | 7c4d3a6c52a86acb022ee7201b1cd0dccb1b8c55 (diff) |
gst: Handle floating references consistently
If a function takes a floating reference parameter, it should also be
sinked in error cases. Otherwise the function behaves differently
between error and normal cases, which is impossible for bindings to
handle.
https://bugzilla.gnome.org/show_bug.cgi?id=747990
-rw-r--r-- | gst/gstbin.c | 4 | ||||
-rw-r--r-- | gst/gstelement.c | 3 | ||||
-rw-r--r-- | gst/gstghostpad.c | 1 | ||||
-rw-r--r-- | gst/gstregistry.c | 2 | ||||
-rw-r--r-- | gst/gstutils.c | 2 |
5 files changed, 5 insertions, 7 deletions
diff --git a/gst/gstbin.c b/gst/gstbin.c index 688988f5a..e1389cd19 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1367,6 +1367,8 @@ adding_itself: GST_OBJECT_LOCK (bin); g_warning ("Cannot add bin '%s' to itself", GST_ELEMENT_NAME (bin)); GST_OBJECT_UNLOCK (bin); + gst_object_ref_sink (element); + gst_object_unref (element); return FALSE; } duplicate_name: @@ -1384,8 +1386,6 @@ had_parent: g_warning ("Element '%s' already has parent", elem_name); GST_OBJECT_UNLOCK (bin); g_free (elem_name); - gst_object_ref_sink (element); - gst_object_unref (element); return FALSE; } } diff --git a/gst/gstelement.c b/gst/gstelement.c index 94efcb48c..e4f68da57 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -734,8 +734,6 @@ had_parent: pad_name, GST_ELEMENT_NAME (element)); GST_OBJECT_UNLOCK (element); g_free (pad_name); - gst_object_ref_sink (pad); - gst_object_unref (pad); return FALSE; } no_direction: @@ -1275,6 +1273,7 @@ gst_element_class_add_pad_template (GstElementClass * klass, /* Found pad with the same name, replace and return */ if (strcmp (templ->name_template, padtempl->name_template) == 0) { + gst_object_ref_sink (padtempl); gst_object_unref (padtempl); template_list->data = templ; return; diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c index b03ae7dbd..cd96668c2 100644 --- a/gst/gstghostpad.c +++ b/gst/gstghostpad.c @@ -615,7 +615,6 @@ parent_failed: g_critical ("Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); GST_OBJECT_UNLOCK (pad); - gst_object_unref (internal); return FALSE; } } diff --git a/gst/gstregistry.c b/gst/gstregistry.c index dbd373a10..198ca5f3f 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -444,6 +444,8 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin) GST_WARNING_OBJECT (registry, "Not replacing plugin because new one (%s) is blacklisted but for a different location than existing one (%s)", plugin->filename, existing_plugin->filename); + /* Keep reference counting consistent */ + gst_object_ref_sink (plugin); gst_object_unref (plugin); GST_OBJECT_UNLOCK (registry); return FALSE; diff --git a/gst/gstutils.c b/gst/gstutils.c index ec3a33579..94fb51369 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -1475,7 +1475,6 @@ ghost_up (GstElement * e, GstPad * pad) if (!gst_element_add_pad ((GstElement *) parent, gpad)) { g_warning ("Pad named %s already exists in element %s\n", GST_OBJECT_NAME (gpad), GST_OBJECT_NAME (parent)); - gst_object_unref ((GstObject *) gpad); GST_STATE_UNLOCK (parent); return NULL; } @@ -2059,7 +2058,6 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname, if (!gst_bin_add (GST_BIN (parent), capsfilter)) { GST_ERROR ("Could not add capsfilter"); - gst_object_unref (capsfilter); gst_object_unref (parent); return FALSE; } |