mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
gst/gstregistry.c: When replacing an existing feature in the registry, make sure to continue holding a reference unti...
Original commit message from CVS: * gst/gstregistry.c: (gst_registry_add_feature): When replacing an existing feature in the registry, make sure to continue holding a reference until we've replaced the name string within our feature hash table. Make sure to use g_hash_table_replace instead of g_hash_table_insert to ensure the new name string is used as a key instead of the old one that we're about to free. Fixes: #462085
This commit is contained in:
parent
54852ef376
commit
0bc0a5a622
2 changed files with 18 additions and 3 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-07-31 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst/gstregistry.c: (gst_registry_add_feature):
|
||||
When replacing an existing feature in the registry, make sure to
|
||||
continue holding a reference until we've replaced the name string
|
||||
within our feature hash table. Make sure to use g_hash_table_replace
|
||||
instead of g_hash_table_insert to ensure the new name string is used
|
||||
as a key instead of the old one that we're about to free.
|
||||
Fixes: #462085
|
||||
|
||||
2007-07-31 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
|
||||
|
|
|
@ -445,15 +445,20 @@ gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
|
|||
if (G_UNLIKELY (existing_feature)) {
|
||||
GST_DEBUG_OBJECT (registry, "replacing existing feature %p (%s)",
|
||||
existing_feature, feature->name);
|
||||
/* Remove the existing feature from the list now, before we insert the new
|
||||
* one, but don't unref yet because the hash is still storing a reference to * it. */
|
||||
registry->features = g_list_remove (registry->features, existing_feature);
|
||||
/* no need to remove from feature_hash, as insert will replace the value */
|
||||
gst_object_unref (existing_feature);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (registry, "adding feature %p (%s)", feature, feature->name);
|
||||
|
||||
registry->features = g_list_prepend (registry->features, feature);
|
||||
g_hash_table_insert (registry->feature_hash, feature->name, feature);
|
||||
g_hash_table_replace (registry->feature_hash, feature->name, feature);
|
||||
|
||||
if (G_UNLIKELY (existing_feature)) {
|
||||
/* We unref now. No need to remove the feature name from the hash table, it * got replaced by the new feature */
|
||||
gst_object_unref (existing_feature);
|
||||
}
|
||||
|
||||
gst_object_ref (feature);
|
||||
gst_object_sink (feature);
|
||||
|
|
Loading…
Reference in a new issue