diff --git a/src/parser/command_list/command_list.c b/src/parser/command_list/command_list.c index 7763987..76477ac 100644 --- a/src/parser/command_list/command_list.c +++ b/src/parser/command_list/command_list.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 17:49:46 by khais #+# #+# */ -/* Updated: 2025/03/04 13:48:56 by khais ### ########.fr */ +/* Updated: 2025/03/04 15:05:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -65,12 +65,12 @@ static void cmdlist_builder_delimit( t_cmdlist_builder *builder, t_wordlist **words) { - wordlist_debug(builder->current_wordlist); builder->cmdlist->pipelines[builder->idx] = pipeline_from_wordlist(builder->current_wordlist); if (builder->cmdlist->pipelines[builder->idx] == NULL) { cmdlist_builder_error(builder); + wordlist_destroy(*words); return ; } if (cmdlist_builder_at_last_pipeline(builder)) @@ -78,6 +78,7 @@ static void cmdlist_builder_delimit( else builder->cmdlist->operators[builder->idx] = match_op(builder->current_word->word); + wordlist_destroy(builder->current_wordlist); builder->current_wordlist = NULL; worddesc_destroy(builder->current_word); builder->current_word = wordlist_pop(words); diff --git a/tests/parse_command_lists.c b/tests/parse_command_lists.c index a477200..e3d7cce 100644 --- a/tests/parse_command_lists.c +++ b/tests/parse_command_lists.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 17:40:48 by khais #+# #+# */ -/* Updated: 2025/03/04 13:43:39 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:54:03 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,8 @@ #include "unistd.h" #include +extern void __lsan_do_leak_check(void); + static t_cmdlist *parse_command_list(char *input) { ft_dprintf(STDERR_FILENO, "Now checking command list with input [%s]\n", input); @@ -173,10 +175,9 @@ static void test_parse_command_list_invalid_pipeline(void) ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); t_cmdlist *cmd = parse_command_list("echo this | | cat -e || echo does not work"); assert(cmd == NULL); + cmdlist_destroy(cmd); } -extern void __lsan_do_leak_check(void); - int main(void) { test_parse_command_list_invalid_pipeline();