From fb6ad83ace3aa4c7fb912b202754161ae8c1da65 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 6 Jul 2012 14:06:04 -0400 Subject: user source: use threadsafe init for shmdir Otherwise it's possible for multiple threads to initialise it at the same time. Each thread will come up with the same value anyway, but it's a string, so we will leak all but one of them. --- engine/dconf-engine-source-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/dconf-engine-source-user.c b/engine/dconf-engine-source-user.c index dba655f..7c44b79 100644 --- a/engine/dconf-engine-source-user.c +++ b/engine/dconf-engine-source-user.c @@ -41,8 +41,8 @@ dconf_engine_source_user_open_shm (const gchar *name) void *memory; gint fd; - if (shmdir == NULL) - shmdir = g_build_filename (g_get_user_runtime_dir (), "dconf", NULL); + if (g_once_init_enter (&shmdir)) + g_once_init_leave (&shmdir, g_build_filename (g_get_user_runtime_dir (), "dconf", NULL)); filename = g_build_filename (shmdir, name, NULL); memory = NULL; -- cgit v1.2.1