Sophie

Sophie

distrib > Mageia > 3 > i586 > by-pkgid > c87d04b1fbec8b5794526daf81572403 > files > 9

gtk+2.0-2.24.17-1.mga3.src.rpm

--- gtk+-2.6.9/gtk/gtkfilesel.c.fileselectorfallback	2005-07-01 17:32:55.000000000 +0200
+++ gtk+-2.6.9/gtk/gtkfilesel.c	2005-08-02 08:45:05.000000000 +0200
@@ -2674,6 +2674,7 @@
   gchar *utf8_cwd;
   CompletionState *new_state;
   gint tries = 0;
+  gint fallback = 0;
 
   new_state = g_new (CompletionState, 1);
 
@@ -2698,8 +2699,29 @@
 
   if (!new_state->reference_dir)
     {
+      /* don't leak updated_text and the_completion.text */
+      if (new_state->the_completion.text)
+      g_free (new_state->the_completion.text);
+      if (new_state->updated_text)
+	g_free (new_state->updated_text);
       /* Directories changing from underneath us, grumble */
-      strcpy (utf8_cwd, G_DIR_SEPARATOR_S);
+      if (fallback == 0) {
+	if (utf8_cwd) {
+	  g_free (utf8_cwd);
+	}
+	utf8_cwd = g_strdup (G_DIR_SEPARATOR_S);
+	fallback = 1;
+      }
+      else {
+	if (fallback == 1) { /* last try with user home dir */
+	  g_free (utf8_cwd);
+	  utf8_cwd = g_filename_to_utf8 (g_get_home_dir (), -1, NULL, NULL, NULL);
+	  fallback = 2;
+	}
+	else {
+	  g_error ("no readable fallback directory found for GtkFileSelector, exiting");
+	}
+      }
       if (tries < 2)
 	goto tryagain;
     }