diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-29 21:22:09 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-29 21:22:09 +0530 |
commit | 46f3de7578f57a9839b92e9e5194fe22730588bd (patch) | |
tree | b6be3170e506a4bee03afd7cb8a129ed94d6dfbd /src | |
parent | 8bd11605fe7c106077bf75f96cc1c921220ad034 (diff) |
copy: free(output_path) properly
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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; } |