[glib/glib-2-32] glib: fix g_reload_user_special_dirs_cache



commit 57214e812d6279490d794902d44180bf25d877da
Author: Marc-Antoine Perennou <Marc-Antoine Perennou com>
Date:   Tue May 22 21:56:10 2012 +0200

    glib: fix g_reload_user_special_dirs_cache
    
    We handle a special case for G_USER_DIRECTORY_DESKTOP
    when we init the values but drop it when we reload them.
    Fix this by preferring old values to NULL
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676594
    
    Signed-off-by: Marc-Antoine Perennou <Marc-Antoine Perennou com>

 glib/gutils.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/glib/gutils.c b/glib/gutils.c
index 7765d5a..42a98fc 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -1731,14 +1731,18 @@ g_reload_user_special_dirs_cache (void)
       /* only leak changed directories */
       for (i = 0; i < G_USER_N_DIRECTORIES; i++)
         {
-	  old_val = old_g_user_special_dirs[i];
-	  if (g_strcmp0 (old_val, g_user_special_dirs[i]) == 0)
+          old_val = old_g_user_special_dirs[i];
+          if (g_user_special_dirs[i] == NULL)
             {
-	      /* don't leak */
-	      g_free (g_user_special_dirs[i]);
-	      g_user_special_dirs[i] = old_val;
+              g_user_special_dirs[i] = old_val;
             }
-	  else
+          else if (g_strcmp0 (old_val, g_user_special_dirs[i]) == 0)
+            {
+              /* don't leak */
+              g_free (g_user_special_dirs[i]);
+              g_user_special_dirs[i] = old_val;
+            }
+          else
             g_free (old_val);
         }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]