Package: gtk+2.0 / 2.24.32-3

FileChooserDefault-Avoid-printf-ing-a-NULL-char.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Daniel Boles <dboles.src@gmail.com>
Date: Fri, 22 Jun 2018 15:10:56 +0100
Subject: 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.

Bug: https://gitlab.gnome.org/GNOME/gtk/issues/1169
Origin: upstream, 2.24.33, commit:168434c4a1ba90609b6f58d0098436c6be7be75b
---
 gtk/gtkfilechooserdefault.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index fb982a3..c113542 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