info: return existing category if a debug category is registered twice

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
This commit is contained in:
Víctor Manuel Jáquez Leal 2013-12-07 19:32:58 +01:00 committed by Tim-Philipp Müller
parent 53ae1b2c9c
commit 24a766a13b

View 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);
}