From b2b44a0810554c521dd4b067f4b885bcb7e4acda Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Wed, 23 Jun 2010 16:02:07 +0900 Subject: [PATCH] libeek: make temporary copies of config parameters in #set_model() etc. --- eek/eek-xkl-layout.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/eek/eek-xkl-layout.c b/eek/eek-xkl-layout.c index 1909b8f3..7cc581a5 100644 --- a/eek/eek-xkl-layout.c +++ b/eek/eek-xkl-layout.c @@ -400,7 +400,11 @@ eek_xkl_layout_set_model (EekXklLayout *layout, g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); - config->model = (gchar *)model; + /* config->model will be freed on g_object_unref (config) */ + if (model) + config->model = g_strdup (model); + else + config->model = NULL; success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); return success; @@ -424,7 +428,11 @@ eek_xkl_layout_set_layouts (EekXklLayout *layout, g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); - config->layouts = layouts; + /* config->layouts will be freed on g_object_unref (config) */ + if (layouts) + config->layouts = g_strdupv (layouts); + else + config->layouts = layouts; success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); return success; @@ -448,7 +456,11 @@ eek_xkl_layout_set_variants (EekXklLayout *layout, g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); - config->variants = variants; + /* config->variants will be freed on g_object_unref (config) */ + if (variants) + config->variants = g_strdupv (variants); + else + config->variants = NULL; success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); return success; @@ -472,7 +484,11 @@ eek_xkl_layout_set_options (EekXklLayout *layout, g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); - config->options = options; + /* config->options will be freed on g_object_unref (config) */ + if (options) + config->options = options; + else + config->options = NULL; success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); return success;