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
This commit is contained in:
Bastien Nocera 2021-04-28 23:44:20 +02:00
parent e024a542b0
commit 44aa328dc3

View File

@ -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;