libsysprof: avoid an extra string copy

This commit is contained in:
Christian Hergert
2023-08-31 14:16:17 -07:00
parent 4a668f6860
commit 5c489a4499

View File

@ -252,7 +252,8 @@ access_path_from_container (const char *path)
{ {
if ((in_flatpak && !g_str_has_prefix (path, "/home/")) || in_podman) if ((in_flatpak && !g_str_has_prefix (path, "/home/")) || in_podman)
return g_build_filename ("/var/run/host", path, NULL); return g_build_filename ("/var/run/host", path, NULL);
return g_strdup (path);
return NULL;
} }
static SysprofElf * static SysprofElf *
@ -478,7 +479,10 @@ sysprof_elf_loader_load (SysprofElfLoader *self,
continue; continue;
if (in_flatpak || in_podman) if (in_flatpak || in_podman)
path = container_path = access_path_from_container (path); {
if ((container_path = access_path_from_container (path)))
path = container_path;
}
/* Lookup to see if we've already parsed this ELF and handle cases where /* Lookup to see if we've already parsed this ELF and handle cases where
* we've failed to load it too. In the case we failed to load a key is * we've failed to load it too. In the case we failed to load a key is