diff options
author | Sebastian Rasmussen <sebras@hotmail.com> | 2013-10-19 17:39:35 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2013-11-12 09:54:04 +0100 |
commit | 4036f210af2ae6081b5c79971a9068ab43421b7a (patch) | |
tree | 613aa548c75ddeee993633a555665bb201d39a2a /gst/rtsp-server/rtsp-permissions.c | |
parent | eee8b0db8835716e81e9c42c1f9ee58dbb04e2f1 (diff) |
permissions: Fix refcounting when adding/removing roles
Previously a role that was removed was unreffed twice, and when
replacing an existing role the replaced role was freed while still being
referenced. Both bugs are now fixed.
See https://bugzilla.gnome.org/show_bug.cgi?id=710202
Diffstat (limited to 'gst/rtsp-server/rtsp-permissions.c')
-rw-r--r-- | gst/rtsp-server/rtsp-permissions.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/gst/rtsp-server/rtsp-permissions.c b/gst/rtsp-server/rtsp-permissions.c index 25872c6..ae60b96 100644 --- a/gst/rtsp-server/rtsp-permissions.c +++ b/gst/rtsp-server/rtsp-permissions.c @@ -161,7 +161,6 @@ gst_rtsp_permissions_add_role_valist (GstRTSPPermissions * permissions, GstRTSPPermissionsImpl *impl = (GstRTSPPermissionsImpl *) permissions; GstStructure *structure; guint i, len; - gboolean found; g_return_if_fail (GST_IS_RTSP_PERMISSIONS (permissions)); g_return_if_fail (gst_mini_object_is_writable (&permissions->mini_object)); @@ -172,23 +171,18 @@ gst_rtsp_permissions_add_role_valist (GstRTSPPermissions * permissions, g_return_if_fail (structure != NULL); len = impl->roles->len; - found = FALSE; for (i = 0; i < len; i++) { GstStructure *entry = g_ptr_array_index (impl->roles, i); if (gst_structure_has_name (entry, role)) { - gst_structure_free (entry); - found = TRUE; + g_ptr_array_remove_index_fast (impl->roles, i); break; } } gst_structure_set_parent_refcount (structure, &impl->permissions.mini_object.refcount); - if (!found) - g_ptr_array_add (impl->roles, structure); - else - g_ptr_array_index (impl->roles, i) = structure; + g_ptr_array_add (impl->roles, structure); } /** @@ -215,7 +209,6 @@ gst_rtsp_permissions_remove_role (GstRTSPPermissions * permissions, if (gst_structure_has_name (entry, role)) { g_ptr_array_remove_index_fast (impl->roles, i); - gst_structure_free (entry); break; } } |