From bd8c1532e71862bfe548c0a2c8bea9735c9cd60c Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 5 Oct 2013 03:04:03 +0200 Subject: [PATCH] Protect gswe_init() from re-entry As gswe_init() calls functions that call gswe_init(), gswe_init() must be protected against such re-entry. --- src/swe-glib.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/swe-glib.c b/src/swe-glib.c index fe109f1..14cced1 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -42,6 +42,7 @@ GHashTable *gswe_house_system_info_table; GHashTable *gswe_aspect_info_table; GHashTable *gswe_antiscion_axis_info_table; GsweTimestamp *gswe_full_moon_base_date; +static gboolean gswe_initializing = FALSE; #define ADD_PLANET(ht, v, i, s, r, n, o, h) \ (v) = gswe_planet_info_new(); \ @@ -119,15 +120,21 @@ gswe_init(void) GsweAspectInfo *aspect_info; GsweAntiscionAxisInfo *antiscion_axis_info; + if (gswe_initialized) { + return; + } + + if (gswe_initializing) { + return; + } + + gswe_initializing = TRUE; + /* Before 2.34, g_type_init() must have been called. Let's do it! */ #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); #endif - if (gswe_initialized) { - return; - } - bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");