From d4c6f1c4a0454d6ed830bcd6dd427c83f7dba220 Mon Sep 17 00:00:00 2001 From: "P. F. Chimento" Date: Sat, 20 Apr 2013 17:42:42 +0200 Subject: [PATCH] Fix overenthusiastic g_free() of Glk startup data --- libchimara/chimara-glk.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index aea0f69..9582159 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -1137,19 +1137,21 @@ free_startup_data(struct StartupData *startup) while(i < startup->args.argc) g_free(startup->args.argv[i++]); g_free(startup->args.argv); + g_free(startup); } -/* glk_enter() is the actual function called in the new thread in which glk_main() runs. */ +/* glk_enter() is the actual function called in the new thread in which +glk_main() runs. Takes ownership of @startup and will free it. */ static gpointer glk_enter(struct StartupData *startup) { extern GPrivate *glk_data_key; g_private_set(glk_data_key, startup->glk_data); - + /* Acquire the Glk thread's references to the input queues */ g_async_queue_ref(startup->glk_data->char_input_queue); g_async_queue_ref(startup->glk_data->line_input_queue); - + /* Run startup function */ if(startup->glkunix_startup_code) { startup->glk_data->in_startup = TRUE; @@ -1161,18 +1163,17 @@ glk_enter(struct StartupData *startup) return NULL; } } - + /* Run main function */ glk_main_t glk_main = startup->glk_main; - + /* COMPAT: avoid usage of slices */ - g_free(startup); - g_signal_emit_by_name(startup->glk_data->self, "started"); + g_signal_emit_by_name(startup->glk_data->self, "started"); glk_main(); free_startup_data(startup); glk_exit(); /* Run shutdown code in glk_exit() even if glk_main() returns normally */ g_assert_not_reached(); /* because glk_exit() calls g_thread_exit() */ - return NULL; + return NULL; } /** -- 2.30.2