From 066c7b81211fe203d2f7a4c7556c05bd53293097 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 9 Sep 2011 19:54:06 -0400 Subject: [PATCH] GRegex: fix thread-unsafe initialiser code --- glib/gregex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glib/gregex.c b/glib/gregex.c index d07036b4f..74a2b0fa3 100644 --- a/glib/gregex.c +++ b/glib/gregex.c @@ -1187,7 +1187,7 @@ g_regex_new (const gchar *pattern, gint erroffset; gint errcode; gboolean optimize = FALSE; - static gboolean initialized = FALSE; + static gsize initialised; unsigned long int pcre_compile_options; g_return_val_if_fail (pattern != NULL, NULL); @@ -1195,7 +1195,7 @@ g_regex_new (const gchar *pattern, g_return_val_if_fail ((compile_options & ~G_REGEX_COMPILE_MASK) == 0, NULL); g_return_val_if_fail ((match_options & ~G_REGEX_MATCH_MASK) == 0, NULL); - if (!initialized) + if (g_once_init_enter (&initialised)) { gint support; const gchar *msg; @@ -1218,7 +1218,7 @@ g_regex_new (const gchar *pattern, return NULL; } - initialized = TRUE; + g_once_init_leave (&initialised, TRUE); } /* G_REGEX_OPTIMIZE has the same numeric value of PCRE_NO_UTF8_CHECK, -- 2.34.1