FileChooserDefault: Avoid printf()ing a NULL char*
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
This commit is contained in:
parent
3c92c216a0
commit
168434c4a1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user