anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
Blob Blame History Raw
From 60cf5a261b6b521b92801447aeace9c63a282ddc Mon Sep 17 00:00:00 2001
From: Ronny Chevalier <chevalier.ronny@gmail.com>
Date: Fri, 10 Apr 2015 15:44:02 +0200
Subject: [PATCH] shared: fix memleak

path was used for 2 purposes but it was not freed before being reused.

(cherry picked from commit 0d67448869bd881fd6aea57de6da98800395cf1f)

Cherry-picked from: 146ec8e
Resolves: #1222517
---
 src/shared/install.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 92b8d6e8e..efd489ec0 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -515,7 +515,7 @@ static int find_symlinks_in_scope(
                 UnitFileState *state) {
 
         int r;
-        _cleanup_free_ char *path = NULL;
+        _cleanup_free_ char *normal_path = NULL, *runtime_path = NULL;
         bool same_name_link_runtime = false, same_name_link = false;
 
         assert(scope >= 0);
@@ -523,11 +523,11 @@ static int find_symlinks_in_scope(
         assert(name);
 
         /* First look in runtime config path */
-        r = get_config_path(scope, true, root_dir, &path);
+        r = get_config_path(scope, true, root_dir, &normal_path);
         if (r < 0)
                 return r;
 
-        r = find_symlinks(name, path, &same_name_link_runtime);
+        r = find_symlinks(name, normal_path, &same_name_link_runtime);
         if (r < 0)
                 return r;
         else if (r > 0) {
@@ -536,11 +536,11 @@ static int find_symlinks_in_scope(
         }
 
         /* Then look in the normal config path */
-        r = get_config_path(scope, false, root_dir, &path);
+        r = get_config_path(scope, false, root_dir, &runtime_path);
         if (r < 0)
                 return r;
 
-        r = find_symlinks(name, path, &same_name_link);
+        r = find_symlinks(name, runtime_path, &same_name_link);
         if (r < 0)
                 return r;
         else if (r > 0) {