anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
923a60
From 60cf5a261b6b521b92801447aeace9c63a282ddc Mon Sep 17 00:00:00 2001
923a60
From: Ronny Chevalier <chevalier.ronny@gmail.com>
923a60
Date: Fri, 10 Apr 2015 15:44:02 +0200
923a60
Subject: [PATCH] shared: fix memleak
923a60
923a60
path was used for 2 purposes but it was not freed before being reused.
923a60
923a60
(cherry picked from commit 0d67448869bd881fd6aea57de6da98800395cf1f)
923a60
923a60
Cherry-picked from: 146ec8e
923a60
Resolves: #1222517
923a60
---
923a60
 src/shared/install.c | 10 +++++-----
923a60
 1 file changed, 5 insertions(+), 5 deletions(-)
923a60
923a60
diff --git a/src/shared/install.c b/src/shared/install.c
923a60
index 92b8d6e8ef..efd489ec08 100644
923a60
--- a/src/shared/install.c
923a60
+++ b/src/shared/install.c
923a60
@@ -515,7 +515,7 @@ static int find_symlinks_in_scope(
923a60
                 UnitFileState *state) {
923a60
 
923a60
         int r;
923a60
-        _cleanup_free_ char *path = NULL;
923a60
+        _cleanup_free_ char *normal_path = NULL, *runtime_path = NULL;
923a60
         bool same_name_link_runtime = false, same_name_link = false;
923a60
 
923a60
         assert(scope >= 0);
923a60
@@ -523,11 +523,11 @@ static int find_symlinks_in_scope(
923a60
         assert(name);
923a60
 
923a60
         /* First look in runtime config path */
923a60
-        r = get_config_path(scope, true, root_dir, &path);
923a60
+        r = get_config_path(scope, true, root_dir, &normal_path);
923a60
         if (r < 0)
923a60
                 return r;
923a60
 
923a60
-        r = find_symlinks(name, path, &same_name_link_runtime);
923a60
+        r = find_symlinks(name, normal_path, &same_name_link_runtime);
923a60
         if (r < 0)
923a60
                 return r;
923a60
         else if (r > 0) {
923a60
@@ -536,11 +536,11 @@ static int find_symlinks_in_scope(
923a60
         }
923a60
 
923a60
         /* Then look in the normal config path */
923a60
-        r = get_config_path(scope, false, root_dir, &path);
923a60
+        r = get_config_path(scope, false, root_dir, &runtime_path);
923a60
         if (r < 0)
923a60
                 return r;
923a60
 
923a60
-        r = find_symlinks(name, path, &same_name_link);
923a60
+        r = find_symlinks(name, runtime_path, &same_name_link);
923a60
         if (r < 0)
923a60
                 return r;
923a60
         else if (r > 0) {