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:
Jan Schmidt 2007-07-31 11:51:38 +00:00
parent 54852ef376
commit 0bc0a5a622
2 changed files with 18 additions and 3 deletions

View file

@ -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),

View file

@ -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);