anitazha / rpms / systemd

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