From e745796ffea1580b7d9263305ee57233536b3365 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Wed, 22 Jan 2025 17:04:26 +0100 Subject: Add free to get_cmd_path --- src/get_cmd_path.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/get_cmd_path.c') diff --git a/src/get_cmd_path.c b/src/get_cmd_path.c index 01f24b1..f882734 100644 --- a/src/get_cmd_path.c +++ b/src/get_cmd_path.c @@ -6,7 +6,7 @@ /* By: chuhlig +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:19:59 by chuhlig #+# #+# */ -/* Updated: 2025/01/22 16:17:27 by chuhlig ### ########.fr */ +/* Updated: 2025/01/22 16:59:48 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -66,9 +66,11 @@ static char *find_in_path(char *cmd, t_env *env, int *return_code) char *cur_path; char *cmd_path; char **path; + char **path_start; path = get_split_path(env); + path_start = path; cmd_path = NULL; while (*path) { @@ -76,17 +78,18 @@ static char *find_in_path(char *cmd, t_env *env, int *return_code) free(cmd_path); cur_path = ft_strjoin(*path, "/"); if (!cur_path) - return (NULL); + return (ft_free_split(path_start), NULL); cmd_path = ft_strjoin(cur_path, cmd); free(cur_path); if (!cmd_path) - return (NULL); + return (ft_free_split(path_start), NULL); if (access(cmd_path, X_OK) != -1) - return (cmd_path); + return (ft_free_split(path_start), cmd_path); path++; } *return_code = 127; free(cmd_path); + ft_free_split(path_start); command_not_found_error(cmd); return (NULL); } -- cgit v1.2.3