aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-06-17 12:47:05 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-06-17 12:47:05 +0530
commit9d7959bc4b2f70f1d22e296fca0c7a2cc834789a (patch)
treeb3973bdf15347e488150fd03c63958317127e32a
parent8f09884fa5af21358fd34f9fd98b130a0318a696 (diff)
(file handling): fix memory leak
-rw-r--r--msg.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/msg.c b/msg.c
index 010f508..4be1243 100644
--- a/msg.c
+++ b/msg.c
@@ -183,7 +183,8 @@ handle_file(const char *path)
asprintf(&outpath, "%s/%s", OUTPUT, path);
}
- char *directory = dirname(strdup(outpath));
+ char *temp_outpath = strdup(outpath);
+ char *directory = dirname(temp_outpath);
char *next = calloc(strlen(directory) + 1, sizeof(char));
strcpy(next, "");
@@ -198,6 +199,9 @@ handle_file(const char *path)
mkdir(next, 0700);
}
+ free(next);
+ free(temp_outpath);
+
FILE *in = fopen(inpath, "r");
FILE *out = fopen(outpath, "w");