summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Boles <dboles.src@gmail.com>2018-06-22 15:10:56 +0100
committerDaniel Boles <dboles.src@gmail.com>2018-06-22 15:10:56 +0100
commit168434c4a1ba90609b6f58d0098436c6be7be75b (patch)
tree5e6e33aff0cde78a88fab19aaaee7c0f30351102
parent3c92c216a04bea393ebbd68c7ea8de37714d6a69 (diff)
downloadgtk+-dboles/gtk2-filechooser-bookmark-null-name.tar.gz
FileChooserDefault: Avoid printf()ing a NULL char*dboles/gtk2-filechooser-bookmark-null-name
If the name of the bookmark is NULL, using it with the printf %s format specifier is undefined behaviour per the C Standard. Besides, it would result in a completely unhelpful tooltip even if it were well-defined. We already have an else case for when nothing is selected, which avoids trying to use the name, so ensure we go there if it's NULL or empty too. https://gitlab.gnome.org/GNOME/gtk/issues/1169
-rw-r--r--gtk/gtkfilechooserdefault.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index fb982a3b89..c11354248e 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -2810,8 +2810,8 @@ bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
{
GtkTreeIter iter;
gboolean removable = FALSE;
+ gboolean have_name = FALSE;
gchar *name = NULL;
- gchar *tip;
if (shortcuts_get_selected (impl, &iter))
{
@@ -2821,6 +2821,13 @@ bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
-1);
gtk_widget_set_sensitive (impl->browse_shortcuts_remove_button, removable);
+ have_name = name != NULL && name[0] != '\0';
+ }
+
+ if (have_name)
+ {
+ char *tip;
+
if (removable)
tip = g_strdup_printf (_("Remove the bookmark '%s'"), name);
else