summaryrefslogtreecommitdiff
path: root/backport-Fix-memleak-when-fsmRename-failed-in-fsmCommit.patch
blob: 889cf6ea88487dcc151dfef2a8e8f6f80100dbf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 688c4ad34d197055eb8f58fb4e45065af881598c Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Mon, 28 Nov 2022 11:10:19 +0800
Subject: [PATCH 1/3] Fix memleak when fsmRename failed in fsmCommit

The "dest" is alloced in fsmFsPath but not freed when fsmRename failed
in fsmCommit. Fix it.
---
 lib/fsm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/fsm.c b/lib/fsm.c
index 7987abbc9..e38155df7 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -782,7 +782,8 @@ static int fsmCommit(int dirfd, char **path, rpmfi fi, rpmFileAction action, con
 		}
 		free(*path);
 		*path = dest;
-	    }
+	    } else
+		free(dest);
 	}
     }
 
-- 
2.27.0