From 5c489a4499f0458f2f67b2476c2794636b31e040 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 31 Aug 2023 14:16:17 -0700 Subject: [PATCH] libsysprof: avoid an extra string copy --- src/libsysprof/sysprof-elf-loader.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libsysprof/sysprof-elf-loader.c b/src/libsysprof/sysprof-elf-loader.c index 4b3ad33e..c104b37b 100644 --- a/src/libsysprof/sysprof-elf-loader.c +++ b/src/libsysprof/sysprof-elf-loader.c @@ -252,7 +252,8 @@ access_path_from_container (const char *path) { if ((in_flatpak && !g_str_has_prefix (path, "/home/")) || in_podman) return g_build_filename ("/var/run/host", path, NULL); - return g_strdup (path); + + return NULL; } static SysprofElf * @@ -478,7 +479,10 @@ sysprof_elf_loader_load (SysprofElfLoader *self, continue; 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 * we've failed to load it too. In the case we failed to load a key is