[Xfce4-commits] <thunar:xfce-4.8> Prevent falling back to an unexpected locale (bug #4746).

Jannis Pohlmann noreply at xfce.org
Mon Sep 19 15:22:01 CEST 2011


Updating branch refs/heads/xfce-4.8
         to 970a5fdc1fa28524a085fe678bb0550f532f8d29 (commit)
       from 57bf9e5088cf7ac6e7989541889544637e20a89d (commit)

commit 970a5fdc1fa28524a085fe678bb0550f532f8d29
Author: Jannis Pohlmann <jannis at 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.accounts at gmx.de> and Mark
    Trompell<mark at foresightlinux.org>.

 NEWS                                  |    2 ++
 plugins/thunar-uca/thunar-uca-model.c |    5 +++--
 thunar/thunar-shortcuts-model.c       |    6 +++---
 thunar/thunar-window.c                |    3 ++-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index fa93294..bdb764a 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@
 - Fix segfaults in case icons are missing or not found (bug #7880).
 - Allow exec bit of MS-DOS executables and MSI to be changed 
   (bug #3545).
+- Prevent falling back to an unexpected locale (bug #4746).
+  Patch by Martin Jürgens and Mark Trompell.
 
 1.2.2
 =====
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 fe76be6..33eaa1b 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);
 }
 
 


More information about the Xfce4-commits mailing list