mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
fix(parsing/pipeline): leak when optional pipeline returns NULL
This commit is contained in:
parent
6cc6e6cfb5
commit
9271b7fa92
3 changed files with 18 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 10:46:28 by khais #+# #+# */
|
||||
/* Updated: 2025/04/16 15:43:44 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/17 12:27:05 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include "../redirect/redirect_parse.h"
|
||||
#include "../simple_cmd/simple_cmd_parse.h"
|
||||
#include "../cmd/cmds_parse.h"
|
||||
#include "../cmd/cmd_debug.h"
|
||||
|
||||
t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
|
|
@ -41,11 +42,14 @@ t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
|||
|
||||
t_cmd *minishell_group_or_simple_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
t_cmd *cmd;
|
||||
|
||||
if ((*tokens)->word->token_type == OPEN_PARENTH_TOKEN)
|
||||
{
|
||||
worddesc_destroy(wordlist_pop(tokens));
|
||||
return (minishell_group_cmd_parse(app, tokens));
|
||||
cmd = minishell_group_cmd_parse(app, tokens);
|
||||
}
|
||||
else
|
||||
return (minishell_simple_cmd_parse(app, tokens));
|
||||
cmd = minishell_simple_cmd_parse(app, tokens);
|
||||
return (cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 11:35:08 by khais #+# #+# */
|
||||
/* Updated: 2025/04/16 13:07:51 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/18 09:19:12 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ t_cmd *minishell_pipeline_parse(t_minishell *app, t_wordlist **tokens)
|
|||
return (NULL);
|
||||
opt = minishell_optional_pipeline_parse(app, tokens);
|
||||
if (!opt && ft_errno_get() != FT_ESUCCESS)
|
||||
return (NULL);
|
||||
return (cmd_destroy(subtree), NULL);
|
||||
if (!opt)
|
||||
return (subtree);
|
||||
while (opt)
|
||||
|
|
@ -36,7 +36,8 @@ t_cmd *minishell_pipeline_parse(t_minishell *app, t_wordlist **tokens)
|
|||
if (connec_reorient_subtree(&pipeline, &subtree, &opt, FT_PIPE) == NULL)
|
||||
{
|
||||
app->last_return_value = 1;
|
||||
return (ft_perror("minishell_pipeline_parse"), NULL);
|
||||
return (cmd_destroy(subtree),
|
||||
ft_perror("minishell_pipeline_parse"), NULL);
|
||||
}
|
||||
opt = minishell_optional_pipeline_parse(app, tokens);
|
||||
}
|
||||
|
|
|
|||
7
test.sh
7
test.sh
|
|
@ -697,4 +697,11 @@ expecting <<EOF
|
|||
hello!
|
||||
EOF
|
||||
|
||||
when_run <<EOF "double pipe after echo"
|
||||
echo | |
|
||||
EOF
|
||||
expecting <<"EOF"
|
||||
minishell: syntax error near unexpected token `|'
|
||||
EOF
|
||||
|
||||
finalize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue