From 82af857a5555fb6f8fb93a9e2a6eaf1d4b5bdf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Thu, 5 Apr 2018 15:26:19 +0100 Subject: [PATCH] sysroot: fix several memory leaks --- src/plugins/sysroot/gbp-sysroot-manager.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/sysroot/gbp-sysroot-manager.c b/src/plugins/sysroot/gbp-sysroot-manager.c index 3b9bfa3d7..02514434b 100644 --- a/src/plugins/sysroot/gbp-sysroot-manager.c +++ b/src/plugins/sysroot/gbp-sysroot-manager.c @@ -320,19 +320,21 @@ gbp_sysroot_manager_set_target_path (GbpSysrootManager *self, { g_auto(GStrv) path_parts = NULL; g_autofree gchar *additional_paths = NULL; + g_autofree gchar *found_pkgconfigs = g_steal_pointer (¤t_pkgconfigs); // Prepend the sysroot path to the BASIC_LIBDIRS values path_parts = g_strsplit (BASIC_LIBDIRS, ":", 0); for (gint i = g_strv_length (path_parts) - 1; i >= 0; i--) { g_autofree gchar *path_i = NULL; + g_autofree gchar *previous_pkgconfigs = g_steal_pointer (&found_pkgconfigs); path_i = g_build_path (G_DIR_SEPARATOR_S, path, path_parts[i], NULL); - current_pkgconfigs = g_strjoin (":", path_i, current_pkgconfigs, NULL); + found_pkgconfigs = g_strjoin (":", path_i, previous_pkgconfigs, NULL); } additional_paths = sysroot_manager_find_additional_pkgconfig_paths (self, target); - current_pkgconfigs = g_strjoin (":", current_pkgconfigs, additional_paths, NULL); + current_pkgconfigs = g_strjoin (":", found_pkgconfigs, additional_paths, NULL); gbp_sysroot_manager_set_target_pkg_config_path (self, target, current_pkgconfigs); } @@ -346,7 +348,9 @@ gbp_sysroot_manager_set_target_path (GbpSysrootManager *self, regex = g_regex_new (current_path_escaped, 0, 0, ®ex_error); if (regex_error == NULL) { - current_pkgconfigs = g_regex_replace_literal (regex, current_pkgconfigs, (gssize) -1, 0, path, 0, ®ex_error); + g_autofree gchar *previous_pkgconfigs = g_steal_pointer (¤t_pkgconfigs); + + current_pkgconfigs = g_regex_replace_literal (regex, previous_pkgconfigs, (gssize) -1, 0, path, 0, ®ex_error); if (regex_error == NULL) gbp_sysroot_manager_set_target_pkg_config_path (self, target, current_pkgconfigs); else -- GitLab