Updating branch refs/heads/master to 594aa7b5be815a84f31a12d8ec49052865734855 (commit) from cfab3c6a3b7ad714fc3fe67e84bf0d3b1fc6d4b1 (commit)
commit 594aa7b5be815a84f31a12d8ec49052865734855 Author: Jannis Pohlmann <jan...@xfce.org> Date: Mon Sep 19 15:11:01 2011 +0200 Prevent falling back to an unexpected locale (bug #4746). setlocale() returns a pointer to its internal locale string, so if we want to store the returned string for later use, we need to duplicate it. Patch by Martin Jürgens<martin.accou...@gmx.de> and Mark Trompell<m...@foresightlinux.org>. plugins/thunar-uca/thunar-uca-model.c | 5 +++-- thunar/thunar-shortcuts-model.c | 6 +++--- thunar/thunar-window.c | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/thunar-uca/thunar-uca-model.c b/plugins/thunar-uca/thunar-uca-model.c index d5cb8e4..1f54bb1 100644 --- a/plugins/thunar-uca/thunar-uca-model.c +++ b/plugins/thunar-uca/thunar-uca-model.c @@ -176,7 +176,7 @@ typedef struct { ParserStack *stack; ThunarUcaModel *model; - const gchar *locale; + gchar *locale; GString *name; gboolean name_use; guint name_match; @@ -553,7 +553,7 @@ thunar_uca_model_load_from_file (ThunarUcaModel *uca_model, /* initialize the parser */ parser.stack = xfce_stack_new (ParserStack); parser.model = uca_model; - parser.locale = setlocale (LC_MESSAGES, NULL); + parser.locale = g_strdup (setlocale (LC_MESSAGES, NULL)); parser.name = g_string_new (NULL); parser.icon = g_string_new (NULL); parser.command = g_string_new (NULL); @@ -574,6 +574,7 @@ thunar_uca_model_load_from_file (ThunarUcaModel *uca_model, g_string_free (parser.command, TRUE); g_string_free (parser.icon, TRUE); g_string_free (parser.name, TRUE); + g_free (parser.locale); xfce_stack_free (parser.stack); g_free (content); diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c index 2aae575..8944461 100644 --- a/thunar/thunar-shortcuts-model.c +++ b/thunar/thunar-shortcuts-model.c @@ -869,7 +869,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model) { /* ~/.gtk-bookmarks wasn't there or it was unreadable. * here we recreate it with some useful xdg user special dirs */ - const char *old_locale = NULL; + gchar *old_locale = NULL; gchar *locale = NULL; bindtextdomain (XDG_USER_DIRS_PACKAGE, PACKAGE_LOCALE_DIR); @@ -878,7 +878,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model) #endif /* HAVE_BIND_TEXTDOMAIN_CODESET */ /* save the old locale */ - old_locale = setlocale (LC_MESSAGES, NULL); + old_locale = g_strdup(setlocale (LC_MESSAGES, NULL)); /* set the new locale */ locale = _thunar_get_xdg_user_dirs_locale (); @@ -938,7 +938,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model) /* restore the old locale */ setlocale (LC_MESSAGES, old_locale); - + g_free(old_locale); gtk_tree_path_free (path); /* we try to save the obtained new model */ diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index a6375c2..a42d982 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -618,7 +618,7 @@ thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) #endif /* HAVE_BIND_TEXTDOMAIN_CODESET */ /* save the old locale */ - old_locale = setlocale (LC_MESSAGES, NULL); + old_locale = g_strdup(setlocale (LC_MESSAGES, NULL)); /* set the new locale */ locale = _thunar_get_xdg_user_dirs_locale (); @@ -656,6 +656,7 @@ thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) g_object_unref (home_dir); setlocale (LC_MESSAGES, old_locale); + g_free (old_locale); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits