From df8592268ab1d458007e20b46ce982fdcc1bad5d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 1 Oct 2024 13:15:15 +0100 Subject: [PATCH] gbytes: Add an assertion to placate static analysis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise `scan-build` thinks it’s possible for the `GBytes` to be double-freed, which would indeed happen if `try_steal_and_unref()` were to return `NULL` on this branch. It’s not actually possible for it to return `NULL` here though, as if `bytes->data` were `NULL`, the function would have already returned higher up. Fixes this `scan-build` failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/4359929 Signed-off-by: Philip Withnall --- glib/gbytes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/gbytes.c b/glib/gbytes.c index 5c844899f..73bfd1db0 100644 --- a/glib/gbytes.c +++ b/glib/gbytes.c @@ -490,6 +490,7 @@ try_steal_and_unref (GBytes *bytes, { *size = bytes->size; result = (gpointer)bytes->data; + g_assert (result != NULL); /* otherwise the case of @bytes being freed can’t be distinguished */ g_free (bytes); return result; }