[gtk/wip/hadess/box-guards] box: Fix guards not working




commit 44aa328dc3bf94a6075ca36fc39748e7cae41c9e
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Apr 28 23:44:20 2021 +0200

    box: Fix guards not working
    
    The guards weren't working because we were accessing data inside the
    arguments before checking them. Postpone data access until after the
    guards.
    
    0x00007ffff741203c in gtk_box_pack (box=box@entry=0x0, child=0xe0b1b0, expand=expand@entry=0, 
fill=fill@entry=0, padding=padding@entry=0, pack_type=pack_type@entry=GTK_PACK_START)
        at /usr/src/debug/gtk3-3.24.28-2.fc34.x86_64/gtk/gtkbox.c:1530
    1530      GtkBoxPrivate *private = box->priv;
    (gdb) bt
     #0  0x00007ffff741203c in gtk_box_pack (box=box@entry=0x0, child=0xe0b1b0, expand=expand@entry=0, 
fill=fill@entry=0, padding=padding@entry=0, pack_type=pack_type@entry=GTK_PACK_START)
         at /usr/src/debug/gtk3-3.24.28-2.fc34.x86_64/gtk/gtkbox.c:1530
     #1  0x00007ffff741223c in gtk_box_pack_start (box=box@entry=0x0, child=<optimized out>, 
expand=expand@entry=0, fill=fill@entry=0, padding=padding@entry=0)
         at /usr/src/debug/gtk3-3.24.28-2.fc34.x86_64/gtk/gtkbox.c:2179

 gtk/gtkbox.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 3c4534a092..c372f9c714 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -1526,14 +1526,17 @@ gtk_box_pack (GtkBox      *box,
               guint        padding,
               GtkPackType  pack_type)
 {
-  GtkContainer *container = GTK_CONTAINER (box);
-  GtkBoxPrivate *private = box->priv;
+  GtkContainer *container;
+  GtkBoxPrivate *private;
   GtkBoxChild *child_info;
 
   g_return_val_if_fail (GTK_IS_BOX (box), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
   g_return_val_if_fail (_gtk_widget_get_parent (child) == NULL, NULL);
 
+  container = GTK_CONTAINER (box);
+  private = box->priv;
+
   child_info = g_new (GtkBoxChild, 1);
   child_info->widget = child;
   child_info->padding = padding;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]