[glib] make sure g_set_prgname() gets called only once
- From: Sven Herzberg <herzi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] make sure g_set_prgname() gets called only once
- Date: Fri, 23 Oct 2009 14:25:28 +0000 (UTC)
commit 3dab24828edd8ebfd6d6c8bb20c181fc0d5650a1
Author: Sven Herzberg <herzi gnome-de org>
Date: Fri Oct 23 14:49:38 2009 +0200
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
glib/gutils.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/glib/gutils.c b/glib/gutils.c
index 8b7bfe8..b5e9c19 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");
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]