mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-19 23:28:54 +02:00
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:
@@ -490,6 +490,7 @@ try_steal_and_unref (GBytes *bytes,
|
|||||||
{
|
{
|
||||||
*size = bytes->size;
|
*size = bytes->size;
|
||||||
result = (gpointer)bytes->data;
|
result = (gpointer)bytes->data;
|
||||||
|
g_assert (result != NULL); /* otherwise the case of @bytes being freed can’t be distinguished */
|
||||||
g_free (bytes);
|
g_free (bytes);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user