paned: Protect against NULL variable
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 9 Aug 2022 16:11:01 +0000 (13:11 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 9 Aug 2022 16:59:09 +0000 (13:59 -0300)
The inner loop in gtk_paned_set_focus_child() tries to find the
topmost GtkPaned, however, if the `w` variable ends up becoming
NULL after bubbling up the entire GtkWidget hierarchy, this loop
never breaks.

Check for NULL in this loop.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/5094

gtk/gtkpaned.c

index e5508fc6453b4e4f2617fa64c2889fe3150d816f..a3cb71081aaccb5f26ea8843b92197a9baddeea5 100644 (file)
@@ -1973,7 +1973,7 @@ gtk_paned_set_focus_child (GtkWidget *widget,
           /* If there is one or more paned widgets between us and the
            * focus widget, we want the topmost of those as last_focus
            */
-          for (w = last_focus; w != GTK_WIDGET (paned); w = gtk_widget_get_parent (w))
+          for (w = last_focus; w && w != GTK_WIDGET (paned); w = gtk_widget_get_parent (w))
             if (GTK_IS_PANED (w))
               last_focus = w;