From 57d8de3e3eda11e486003750f674f15c2ea89639 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 1 Aug 2023 19:04:13 +0200 Subject: [PATCH] walker.c: do not memdup initial path --- lib/tree/walker.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/tree/walker.c b/lib/tree/walker.c index e0cb1a5d5..69e5a33a2 100644 --- a/lib/tree/walker.c +++ b/lib/tree/walker.c @@ -316,9 +316,10 @@ sqsh_tree_walker_resolve( struct SqshTreeWalker *walker, const char *path, bool follow_links) { int rv = 0; - char *current_path = sqsh_memdup(path, strlen(path)); + char *current_path_buf = NULL; + const char *current_path = path; for (int i = 0; i < 100; i++) { - rv = tree_walker_resolve(walker, path); + rv = tree_walker_resolve(walker, current_path); if (rv < 0) { goto out; } @@ -334,12 +335,12 @@ sqsh_tree_walker_resolve( if (rv < 0) { goto out; } - free(current_path); - current_path = sqsh_inode_symlink_dup(&inode); + free(current_path_buf); + current_path = current_path_buf = sqsh_inode_symlink_dup(&inode); sqsh__inode_cleanup(&inode); } out: - free(current_path); + free(current_path_buf); return rv; }