From 08897c8d63996e74e6ca3d9ba4ba9d506864ba18 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 13 Oct 2023 15:39:06 +0200 Subject: [PATCH] Fix memory leak - not freeing string holding path --- src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 68a38ec..da1fa1c 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/12 14:52:24 by ljiriste #+# #+# */ -/* Updated: 2023/10/13 13:54:26 by ljiriste ### ########.fr */ +/* Updated: 2023/10/13 15:36:37 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,6 +36,7 @@ int my_open(const char *fname) path = ft_strdup(TEST_DIR); ft_strncat_alloc(&path, fname, ft_strlen(fname)); fd = open(path, O_RDONLY); + free(path); return (fd); } @@ -56,6 +57,7 @@ int create_res_file(const char *fname) path = ft_strdup(RESULT_DIR); ft_strncat_alloc(&path, fname, ft_strlen(fname)); fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + free(path); return (fd); } -- 2.30.2