From: Sven Herzberg Date: Fri, 23 Oct 2009 12:49:38 +0000 (+0200) Subject: make sure g_set_prgname() gets called only once X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=3dab24828edd8ebfd6d6c8bb20c181fc0d5650a1;p=dana%2Fcg-glib.git make sure g_set_prgname() gets called only once * glib/gutils.c: copy the call-once statement from g_set_application_name(); Fixes Bug #563627: g_get_prgname() threadsafety --- diff --git a/glib/gutils.c b/glib/gutils.c index 8b7bfe8a..b5e9c193 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1968,10 +1968,17 @@ g_get_prgname (void) void g_set_prgname (const gchar *prgname) { + gboolean already_set = FALSE; + G_LOCK (g_prgname); - g_free (g_prgname); - g_prgname = g_strdup (prgname); + if (g_prgname) + already_set = TRUE; + else + g_prgname = g_strdup (prgname); G_UNLOCK (g_prgname); + + if (already_set) + g_warning ("g_set_prgname() called multiple times"); } G_LOCK_DEFINE_STATIC (g_application_name); @@ -2038,7 +2045,7 @@ g_set_application_name (const gchar *application_name) G_UNLOCK (g_application_name); if (already_set) - g_warning ("g_set_application() name called multiple times"); + g_warning ("g_set_application_name() called multiple times"); } /**