[gtk/gtk-3-24] gtkstack: fix null pointer dereference
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] gtkstack: fix null pointer dereference
- Date: Sun, 7 Oct 2018 17:32:25 +0000 (UTC)
commit adbaee796de3ccb9b0a95b298fb0bfd00c2fcdd4
Author: Hugo Lefeuvre <hle debian org>
Date: Wed Sep 26 16:59:59 2018 -0400
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
gtk/gtkstack.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 6815488a3e..51a3a732e5 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -2088,12 +2088,14 @@ gtk_stack_draw_slide (GtkWidget *widget,
x += priv->last_visible_surface_allocation.x;
y += priv->last_visible_surface_allocation.y;
-
- if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
- 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)
- y -= (priv->last_visible_widget_height - allocation.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 > allocation.height)
+ y -= priv->last_visible_widget_height - allocation.height;
+ else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
+ y -= (priv->last_visible_widget_height - allocation.height) / 2;
+ }
cairo_save (cr);
cairo_set_source_surface (cr, priv->last_visible_surface, x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]