dir: Don't store a pointer in a gsize

This is, strictly speaking, not allowed. On uncommon architectures like
CHERI, a pointer can be larger than a gsize.

This might also help to avoid AddressSanitizer losing track of
reachability, so that it won't think the array and its contents have
been leaked.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2024-02-14 23:59:46 +00:00
parent 2350ef1111
commit b97704dee6

View File

@@ -1842,16 +1842,16 @@ GPtrArray *
flatpak_get_system_base_dir_locations (GCancellable *cancellable,
GError **error)
{
static gsize array = 0;
static gsize initialized = 0;
static GPtrArray *array = NULL;
if (g_once_init_enter (&array))
if (g_once_init_enter (&initialized))
{
gsize setup_value = 0;
setup_value = (gsize) get_system_locations (cancellable, error);
g_once_init_leave (&array, setup_value);
array = get_system_locations (cancellable, error);
g_once_init_leave (&initialized, 1);
}
return (GPtrArray *) array;
return array;
}
GFile *