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),
(gst_plugin_feature_set_name):
Revert patch from #459466 until after the release and we can work
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);