aboutsummaryrefslogtreecommitdiffstats
path: root/main/glib/0001-gquark-make-sure-quark-is-initialized-before-create-.patch
blob: 565581038f7cf87c760c30c68ee02928ef13a7ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From bc7c6ec8184750289d9d9103a6bdd40adbf4627a Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 30 Jun 2016 09:48:20 +0200
Subject: [PATCH] gquark: make sure quark is initialized before create new
 quark

When g_quark_from_string/g_quark_from_static_string is used to
initialize a global variable it may be called before glib_init's ctor.
Make sure that quark is initialized in those cases.

https://bugzilla.gnome.org/show_bug.cgi?id=768215
---
 glib/gquark.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/glib/gquark.c b/glib/gquark.c
index 9e51a92..2f145ae 100644
--- a/glib/gquark.c
+++ b/glib/gquark.c
@@ -57,6 +57,13 @@ static gint           quark_block_offset = 0;
 void
 g_quark_init (void)
 {
+  static gboolean quark_inited;
+
+  if (quark_inited)
+    return;
+
+  quark_inited = TRUE;
+
   g_assert (quark_seq_id == 0);
   quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
   quarks = g_new (gchar*, QUARK_BLOCK_SIZE);
@@ -209,6 +216,7 @@ g_quark_from_string (const gchar *string)
     return 0;
 
   G_LOCK (quark_global);
+  g_quark_init();
   quark = quark_from_string (string, TRUE);
   G_UNLOCK (quark_global);
 
@@ -243,6 +251,7 @@ g_quark_from_static_string (const gchar *string)
     return 0;
 
   G_LOCK (quark_global);
+  g_quark_init();
   quark = quark_from_string (string, FALSE);
   G_UNLOCK (quark_global);
 
-- 
2.9.0