mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix(parsing/split_cmd): fixed leak when no command
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/12 19:27:31 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/01/18 01:05:44 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/21 17:38:12 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -39,10 +39,13 @@ void free_tab(char ***arr)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while ((*arr)[i])
|
||||
if (*arr)
|
||||
{
|
||||
free((*arr)[i]);
|
||||
i++;
|
||||
while ((*arr)[i])
|
||||
{
|
||||
free((*arr)[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
free(*arr);
|
||||
*arr = NULL;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/01 14:55:06 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/21 12:58:49 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/07/21 17:38:50 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -54,7 +54,7 @@ int exec_single_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2])
|
||||
|
||||
if (!cmd->cmd)
|
||||
{
|
||||
free(cmd->argv);
|
||||
ft_free("a", &(cmd->argv));
|
||||
get_exit_code(0);
|
||||
return (0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/05 13:48:57 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/18 17:15:48 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/21 17:33:54 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/20 17:49:22 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/21 17:44:29 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -24,9 +24,9 @@ t_cmd *split_cmd(char *cmd_av, t_cmd *cmd)
|
||||
cmd->cmd = NULL;
|
||||
return (cmd);
|
||||
}
|
||||
cmd->argv = split;
|
||||
cmd->cmd = ft_strdup(*split);
|
||||
if (!cmd->cmd)
|
||||
return (cmd);
|
||||
cmd->argv = split;
|
||||
return (cmd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user