[gtk/gbsneto/paned-focus-infloop] paned: Protect against NULL child




commit 5e21147f026acf31085f837d8dc977c69a5ea2d2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 9 13:11:01 2022 -0300

    paned: Protect against NULL child
    
    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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index e5508fc645..a3cb71081a 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]