gtkstack: fix null pointer dereference
The gtk_stack_snapshot_slide() function dereferences the last_visible_child pointer without proper != NULL ckeck. This might result in NULL pointer dereference and crash if last_visible_child is invalid. Add a != NULL check before dereferencing the pointer. cherry-picked from https://gitlab.gnome.org/GNOME/gtk/merge_requests/361
This commit is contained in:
parent
b10cde7bdc
commit
adbaee796d
@ -2088,12 +2088,14 @@ gtk_stack_draw_slide (GtkWidget *widget,
|
|||||||
x += priv->last_visible_surface_allocation.x;
|
x += priv->last_visible_surface_allocation.x;
|
||||||
y += priv->last_visible_surface_allocation.y;
|
y += priv->last_visible_surface_allocation.y;
|
||||||
|
|
||||||
|
if (priv->last_visible_child != NULL)
|
||||||
|
{
|
||||||
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
|
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
|
||||||
priv->last_visible_widget_height > allocation.height)
|
priv->last_visible_widget_height > allocation.height)
|
||||||
y -= priv->last_visible_widget_height - allocation.height;
|
y -= priv->last_visible_widget_height - allocation.height;
|
||||||
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
|
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
|
||||||
y -= (priv->last_visible_widget_height - allocation.height) / 2;
|
y -= (priv->last_visible_widget_height - allocation.height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_set_source_surface (cr, priv->last_visible_surface, x, y);
|
cairo_set_source_surface (cr, priv->last_visible_surface, x, y);
|
||||||
|
Loading…
Reference in New Issue
Block a user