info: return existing category if a debug category is registered twice
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sat, 7 Dec 2013 18:32:58 +0000 (19:32 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 7 Dec 2013 19:03:23 +0000 (19:03 +0000)
If a category with the same name is found when creating a new
one, the found category is returned instead of an invalid pointer.
Fixes issue with gst-vaapi (which uses an internal copy of the
codec parsers) caused by commit ccba9130.

https://bugzilla.gnome.org/show_bug.cgi?id=720036

gst/gstinfo.c

index c9d8325..31c9e46 100644 (file)
@@ -1509,7 +1509,7 @@ GstDebugCategory *
 _gst_debug_category_new (const gchar * name, guint color,
     const gchar * description)
 {
-  GstDebugCategory *cat;
+  GstDebugCategory *cat, *catfound;
 
   g_return_val_if_fail (name != NULL, NULL);
 
@@ -1526,10 +1526,12 @@ _gst_debug_category_new (const gchar * name, guint color,
 
   /* add to category list */
   g_mutex_lock (&__cat_mutex);
-  if (_gst_debug_get_category_locked (name)) {
+  catfound = _gst_debug_get_category_locked (name);
+  if (catfound) {
     g_free ((gpointer) cat->name);
     g_free ((gpointer) cat->description);
     g_slice_free (GstDebugCategory, cat);
+    cat = catfound;
   } else {
     __categories = g_slist_prepend (__categories, cat);
   }