mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
leak: resolve one memory leak
This commit is contained in:
parent
5bf4bb8d6a
commit
69b247697c
2 changed files with 7 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <assert.h>
|
||||
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue