dir: Use same mechanism for get_system/user_default_base_dir_location

Also add the same missing valgrind suppression for the system dir
location.
This commit is contained in:
Sebastian Wick
2024-08-01 16:47:11 +02:00
committed by Patrick
parent e5c97002e2
commit efa48c1c21
2 changed files with 19 additions and 7 deletions

View File

@@ -1538,20 +1538,24 @@ flatpak_deploy_new (GFile *dir,
GFile *
flatpak_get_system_default_base_dir_location (void)
{
static gsize path = 0;
static gsize file = 0;
if (g_once_init_enter (&path))
if (g_once_init_enter (&file))
{
gsize setup_value = 0;
const char *path;
const char *system_dir = g_getenv ("FLATPAK_SYSTEM_DIR");
if (system_dir != NULL)
setup_value = (gsize) system_dir;
if (system_dir != NULL && *system_dir != 0)
path = system_dir;
else
setup_value = (gsize) FLATPAK_SYSTEMDIR;
g_once_init_leave (&path, setup_value);
path = FLATPAK_SYSTEMDIR;
setup_value = (gsize) g_file_new_for_path (path);
g_once_init_leave (&file, setup_value);
}
return g_file_new_for_path ((char *) path);
return g_object_ref ((GFile *) file);
}
static FlatpakDirStorageType

View File

@@ -254,6 +254,14 @@
fun:g_file_new_for_path
fun:flatpak_get_user_base_dir_location
}
# Deliberately leaking once per process
{
flatpak_get_system_default_base_dir_location
Memcheck:Leak
...
fun:g_file_new_for_path
fun:flatpak_get_system_default_base_dir_location
}
# https://github.com/ostreedev/ostree/issues/2592
{