From: Lukáš Tyrychtr Date: Mon, 29 May 2023 13:14:51 +0000 (+0200) Subject: GtkStack: Fix a potential crash in gtk_stack_get_first_accessible_child X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~203^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ab7a4f64cb0b3a974f83e2c2b5fba554cbac743a;p=gtk4.git GtkStack: Fix a potential crash in gtk_stack_get_first_accessible_child This one can occur when the stack has no pages. --- diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index 59a3a0357b..dad2036250 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -809,9 +809,12 @@ gtk_stack_accessible_get_first_accessible_child (GtkAccessible *accessible) { GtkStack *stack = GTK_STACK (accessible); GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); - GtkStackPage *page = g_ptr_array_index (priv->children, 0); + GtkAccessible *page_accessible = NULL; - return GTK_ACCESSIBLE (g_object_ref (page)); + if (priv->children->len > 0) + page_accessible = GTK_ACCESSIBLE (g_object_ref (g_ptr_array_index (priv->children, 0))); + + return page_accessible; } static void