diff options
author | Vineeth TM <vineeth.tm@samsung.com> | 2015-07-10 15:36:59 +0900 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-05-17 10:40:37 +0300 |
commit | 7c4d3a6c52a86acb022ee7201b1cd0dccb1b8c55 (patch) | |
tree | 1b368a46999cf33aecd6bbac7bcd37d08ba81f68 | |
parent | eafaefe9da761d5485f5e659ab0b00028297fad5 (diff) |
gst: Fix floating reference inconsistencies in error cases
If a function takes a floating reference and sinks it, it should also do
that in error cases. I.e. call ref_sink() followed by unref().
Otherwise the reference counting behaviour of the function will be
different between the good and the error case, and simply inconsistent.
https://bugzilla.gnome.org/show_bug.cgi?id=747990
-rw-r--r-- | gst/gstbin.c | 6 | ||||
-rw-r--r-- | gst/gstelement.c | 4 | ||||
-rw-r--r-- | gst/gstobject.c | 2 |
3 files changed, 12 insertions, 0 deletions
diff --git a/gst/gstbin.c b/gst/gstbin.c index 3c0b2da38..688988f5a 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -1375,6 +1375,8 @@ duplicate_name: elem_name, GST_ELEMENT_NAME (bin)); GST_OBJECT_UNLOCK (bin); g_free (elem_name); + gst_object_ref_sink (element); + gst_object_unref (element); return FALSE; } had_parent: @@ -1382,6 +1384,8 @@ 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; } } @@ -1537,6 +1541,8 @@ no_function: { g_warning ("adding elements to bin '%s' is not supported", GST_ELEMENT_NAME (bin)); + gst_object_ref_sink (element); + gst_object_unref (element); return FALSE; } } diff --git a/gst/gstelement.c b/gst/gstelement.c index bf579b48f..94efcb48c 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -723,6 +723,8 @@ name_exists: 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; } had_parent: @@ -732,6 +734,8 @@ 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: diff --git a/gst/gstobject.c b/gst/gstobject.c index 32a406d97..50fa1c762 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -693,6 +693,8 @@ had_parent: { GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, object, "set parent failed, object already had a parent"); + gst_object_ref_sink (object); + gst_object_unref (object); GST_OBJECT_UNLOCK (object); return FALSE; } |