Blob Blame History Raw
From 93c4dc92dfbc5fbca8fbda96dc68172430b7095e Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 20 Jul 2018 16:32:44 +0200
Subject: [PATCH] * src/transform.c (transform_save): fix leaks on fchmod fail

If fchmod fails, the early return prevents any cleanup of the function
resources, e.g. the open FILEs.  Use the common error handling instead.

(cherry picked from commit 4d1a3f3cd8d97f852c6e7c50942255d535ad1405)
---
 src/transform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/transform.c b/src/transform.c
index 6a0ce858..176482b9 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -1258,7 +1258,7 @@ int transform_save(struct augeas *aug, struct tree *xfm,
 
         if (fchmod(fileno(fp), 0666 & ~curumsk) < 0) {
             err_status = "create_chmod";
-            return -1;
+            goto done;
         }
     }
 
-- 
2.17.2