gtkplacessidebar: avoid to use a freed string

The string we were using is the representation of the internal text
in the popover entry. However that can be freed before setting the
bookmark label, if i.e. the row is destroyed and therefore the popover
as well.
To avoid that, duplicate the label in a local variable.

One of the consequences is that for those people using development version
we migth screwed its bookmarks file, since the bookmark manager wrote
garbage from the already freed label.

https://bugzilla.gnome.org/show_bug.cgi?id=755215
This commit is contained in:
Carlos Soriano
2015-09-24 15:54:15 +02:00
parent 8eea531f25
commit ecc698a282

View File

@@ -2397,10 +2397,10 @@ static void
do_rename (GtkButton *button,
GtkPlacesSidebar *sidebar)
{
const gchar *new_text;
gchar *new_text;
GFile *file;
new_text = gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry));
new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry)));
file = g_file_new_for_uri (sidebar->rename_uri);
if (!_gtk_bookmarks_manager_has_bookmark (sidebar->bookmarks_manager, file))
@@ -2409,6 +2409,7 @@ do_rename (GtkButton *button,
_gtk_bookmarks_manager_set_bookmark_label (sidebar->bookmarks_manager, file, new_text, NULL);
g_object_unref (file);
g_free (new_text);
g_clear_pointer (&sidebar->rename_uri, g_free);