summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserdefault.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2008-07-06 05:34:03 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2008-07-06 05:34:03 +0000
commit128585147f697173ba807cb40089f5dad209457b (patch)
treeba14c65ffd84948760501bd7d81af15b3327705a /gtk/gtkfilechooserdefault.c
parent36f5e8d776259ea7ded92f4421f0ddcc5d8cde5b (diff)
downloadgtk+-128585147f697173ba807cb40089f5dad209457b.tar.gz
Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not
2008-07-06 Matthias Clasen <mclasen@redhat.com> Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not contain :// * gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_file): Be more robust. Reported by Jelte van der Hoek svn path=/trunk/; revision=20787
Diffstat (limited to 'gtk/gtkfilechooserdefault.c')
-rw-r--r--gtk/gtkfilechooserdefault.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 458bdee71a..c101492ed4 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -1621,37 +1621,42 @@ _gtk_file_chooser_label_for_file (GFile *file)
uri = g_file_get_uri (file);
start = strstr (uri, "://");
- start += 3;
- path = strchr (start, '/');
-
- if (path)
- end = path;
- else
+ if (start)
{
- end = uri + strlen (uri);
- path = "/";
- }
+ start += 3;
+ path = strchr (start, '/');
+ if (path)
+ end = path;
+ else
+ {
+ end = uri + strlen (uri);
+ path = "/";
+ }
- /* strip username */
- p = strchr (start, '@');
- if (p && p < end)
- {
- start = p + 1;
- }
+ /* strip username */
+ p = strchr (start, '@');
+ if (p && p < end)
+ start = p + 1;
- p = strchr (start, ':');
- if (p && p < end)
- end = p;
+ p = strchr (start, ':');
+ if (p && p < end)
+ end = p;
- host = g_strndup (start, end - start);
-
- /* Translators: the first string is a path and the second string
- * is a hostname. Nautilus and the panel contain the same string
- * to translate.
- */
- label = g_strdup_printf (_("%1$s on %2$s"), path, host);
+ host = g_strndup (start, end - start);
+
+ /* Translators: the first string is a path and the second string
+ * is a hostname. Nautilus and the panel contain the same string
+ * to translate.
+ */
+ label = g_strdup_printf (_("%1$s on %2$s"), path, host);
+
+ g_free (host);
+ }
+ else
+ {
+ label = g_strdup (uri);
+ }
- g_free (host);
g_free (uri);
return label;