diff options
author | John Ralls <jralls@ceridwen.us> | 2011-09-12 14:25:45 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2011-09-12 14:30:44 -0500 |
commit | 7550157d66957461439654df272471ce3a135178 (patch) | |
tree | 17a2d7da19e27a0bf4e617fd1d4b9d3bc53b70f9 /gtk/gtkfilesystem.c | |
parent | 70d70a0607d976513cb770a088678dee09fc434b (diff) | |
download | gtk+-7550157d66957461439654df272471ce3a135178.tar.gz |
bgo#514843 - [filechooser] Deal with corrupted .gtk-bookmarks gracefully
We weren't checking for the lines in that file being valid UTF-8 strings.
Diffstat (limited to 'gtk/gtkfilesystem.c')
-rw-r--r-- | gtk/gtkfilesystem.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index f3d8e823a0..e55f83b36b 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -264,6 +264,9 @@ read_bookmarks (GFile *file) if (!*lines[i]) continue; + if (!g_utf8_validate (lines[i], -1, NULL)) + continue; + bookmark = g_slice_new0 (GtkFileSystemBookmark); if ((space = strchr (lines[i], ' ')) != NULL) @@ -289,23 +292,25 @@ save_bookmarks (GFile *bookmarks_file, { GError *error = NULL; GString *contents; + GSList *l; contents = g_string_new (""); - while (bookmarks) + for (l = bookmarks; l; l = l->next) { - GtkFileSystemBookmark *bookmark; + GtkFileSystemBookmark *bookmark = l->data; gchar *uri; - bookmark = bookmarks->data; uri = g_file_get_uri (bookmark->file); + if (!uri) + continue; + g_string_append (contents, uri); if (bookmark->label) g_string_append_printf (contents, " %s", bookmark->label); g_string_append_c (contents, '\n'); - bookmarks = bookmarks->next; g_free (uri); } |