valeriyvdovin / rpms / systemd

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