diff options
author | Hugo Lefeuvre <hle@debian.org> | 2018-09-26 16:59:59 -0400 |
---|---|---|
committer | Hugo Lefeuvre <hle@debian.org> | 2018-09-27 09:53:22 -0400 |
commit | 44655932c4be04cfb6010929df9831e9c04a8ce1 (patch) | |
tree | d5a8187d53bb221d18e7fc8c5507438cd4a22018 /gtk/gtkstack.c | |
parent | a28c7e88397af713b71544258b3d9a69d107229a (diff) | |
download | gtk+-44655932c4be04cfb6010929df9831e9c04a8ce1.tar.gz |
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.
Diffstat (limited to 'gtk/gtkstack.c')
-rw-r--r-- | gtk/gtkstack.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index a3d36a8603..f74894b8e1 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -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); |