gbytes: Add an assertion to placate static analysis

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 <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-10-01 13:15:15 +01:00
parent e4f5c2e9c5
commit df8592268a
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -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 cant be distinguished */
g_free (bytes);
return result;
}