From e5771df6434beff21d233245e9181571d6b25d1c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 18 Nov 2022 17:00:42 +0000 Subject: [PATCH] gvariant: Add an assertion to clarify some tuple logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should quell a scan-build error about dereferencing `member_info` when it’s `NULL` at the end of the function, due to having zero iterations of the `for` loop. Signed-off-by: Philip Withnall --- glib/gvariant-serialiser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/gvariant-serialiser.c b/glib/gvariant-serialiser.c index d5970d2d1..6ebaec7d4 100644 --- a/glib/gvariant-serialiser.c +++ b/glib/gvariant-serialiser.c @@ -983,6 +983,10 @@ gvs_tuple_needed_size (GVariantTypeInfo *type_info, offset = 0; + /* We must go through at least one iteration below. If the tuple had no + * children, it would have a fixed size. */ + g_assert (n_children > 0); + for (i = 0; i < n_children; i++) { guint alignment;