installation: Avoid races when caching the display name

We specifically have to avoid holding the lock while calling
flatpak_installation_get_dir_maybe_no_repo, so we just double check if
it is unset.
This commit is contained in:
Sebastian Wick committed 2026-07-27 13:41:00 +00:00
1 parent 2a0c49ef89
commit 37fe50fc9c
1 file changed
+9 -2
+9 -2
View File
@@ -537,10 +537,17 @@ const char *
flatpak_installation_get_display_name (FlatpakInstallation *self)
{
FlatpakInstallationPrivate *priv = flatpak_installation_get_instance_private (self);
g_autoptr(FlatpakDir) dir = flatpak_installation_get_dir_maybe_no_repo (self);
if (priv->display_name == NULL)
priv->display_name = flatpak_dir_get_display_name (dir);
{
g_autoptr(FlatpakDir) d = flatpak_installation_get_dir_maybe_no_repo (self);
g_autofree char *name = flatpak_dir_get_display_name (d);
G_LOCK (dir);
if (priv->display_name == NULL)
priv->display_name = g_steal_pointer (&name);
G_UNLOCK (dir);
}
return (const char *) priv->display_name;
}