From 70a49e35cc3e8169fabd1852af6748b337b828f3 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 9 Apr 2024 22:50:05 +0100 Subject: [PATCH] gtype: Move an assertion to help out the static analyser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scan-build is worried that `node->data->common.value_table->value_init` will be a `NULL` pointer dereference in the assignment to `node->mutatable_check_cache`. There’s already an assertion immediately below to check against this, so let’s move it up a line to help the static analyser out. Signed-off-by: Philip Withnall Helps: #1767 --- gobject/gtype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gobject/gtype.c b/gobject/gtype.c index b8e724092..cbce0acbd 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -1197,12 +1197,12 @@ type_data_make_W (TypeNode *node, if (value_table->lcopy_format) strcat (p, value_table->lcopy_format); } + node->data->common.value_table = vtable; + g_assert (node->data->common.value_table != NULL); /* paranoid */ node->mutatable_check_cache = (node->data->common.value_table->value_init != NULL && !((G_TYPE_FLAG_VALUE_ABSTRACT | G_TYPE_FLAG_ABSTRACT) & GPOINTER_TO_UINT (type_get_qdata_L (node, static_quark_type_flags)))); - - g_assert (node->data->common.value_table != NULL); /* paranoid */ g_atomic_int_set ((int *) &node->ref_count, 1); }