aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-07-29 21:22:09 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-07-29 21:22:09 +0530
commit46f3de7578f57a9839b92e9e5194fe22730588bd (patch)
treeb6be3170e506a4bee03afd7cb8a129ed94d6dfbd /src
parent8bd11605fe7c106077bf75f96cc1c921220ad034 (diff)
copy: free(output_path) properly
Diffstat (limited to 'src')
-rw-r--r--src/copy.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/copy.c b/src/copy.c
index 6b8679a..6e1b3e3 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -26,13 +26,11 @@ copy_recursively(const char *fpath,
char *output_path = NULL;
asprintf(&output_path, "%s/%s", OUTPUT, path);
- if (typeflag == FTW_D) {
- mkdir(output_path, 0700);
- return FTW_CONTINUE;
- }
+ if (typeflag == FTW_D)
+ goto exit;
if (typeflag != FTW_F)
- return FTW_CONTINUE;
+ goto exit;
FILE *in = fopen(fpath, "r");
size_t size = fsize(in);
@@ -43,9 +41,10 @@ copy_recursively(const char *fpath,
sendfile(out_fd, in_fd, 0, size);
- free(output_path);
close(in_fd);
close(out_fd);
+exit:
+ free(output_path);
return FTW_CONTINUE;
}