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.
This commit is contained in:
Hugo Lefeuvre 2018-09-26 16:59:59 -04:00
parent a28c7e8839
commit 44655932c4

View File

@ -1910,11 +1910,14 @@ gtk_stack_snapshot_slide (GtkWidget *widget,
break;
}
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
priv->last_visible_widget_height > height)
y -= priv->last_visible_widget_height - height;
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
y -= (priv->last_visible_widget_height - height) / 2;
if (priv->last_visible_child != NULL)
{
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
priv->last_visible_widget_height > height)
y -= priv->last_visible_widget_height - height;
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
y -= (priv->last_visible_widget_height - height) / 2;
}
gtk_snapshot_offset (snapshot, x, y);
gtk_snapshot_append_node (snapshot, priv->last_visible_node);