mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(here_doc): segfault when C-c
This commit is contained in:
parent
ee10abacab
commit
083a2bb2a2
4 changed files with 10 additions and 9 deletions
1
Makefile
1
Makefile
|
|
@ -17,6 +17,7 @@ LINCLUDE = -L$(LIBFTDIR)
|
|||
|
||||
ifeq ($(CFLAGS),)
|
||||
CFLAGS = -Wall -Wextra -Werror \
|
||||
$(DEBUG) \
|
||||
|
||||
endif
|
||||
export CFLAGS
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* here_doc_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/17 11:50:08 by kcolin #+# #+# */
|
||||
/* Updated: 2025/05/02 12:47:12 by jguelen ### ########.fr */
|
||||
/* Created: 2025/05/02 14:36:33 by kcolin #+# #+# */
|
||||
/* Updated: 2025/05/02 14:36:33 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -48,7 +48,6 @@ char *finalize(int outfd, char *filename)
|
|||
|
||||
int interupted(int outfd, char *filename)
|
||||
{
|
||||
ft_printf("\n");
|
||||
close(outfd);
|
||||
unlink(filename);
|
||||
free(filename);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/09 16:53:02 by kcolin #+# #+# */
|
||||
/* Updated: 2025/04/30 18:00:28 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/05/02 14:35:54 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,7 +23,8 @@ void redirect_destroy(t_redirect *redirect)
|
|||
{
|
||||
next = redirect->next;
|
||||
free(redirect->here_doc_eof);
|
||||
if (redirect->type == FT_HEREDOC)
|
||||
if (redirect->type == FT_HEREDOC && redirect->redirectee.filename != NULL
|
||||
&& redirect->redirectee.filename->word != NULL)
|
||||
unlink(redirect->redirectee.filename->word);
|
||||
worddesc_destroy(redirect->redirectee.filename);
|
||||
free(redirect->unexpanded_filename);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/30 10:35/43 by kcolin #+# #+# */
|
||||
/* Updated: 2025/04/30 10:35:43 by kcolin ### ########.fr */
|
||||
/* Created: 2025/05/02 14:40:34 by kcolin #+# #+# */
|
||||
/* Updated: 2025/05/02 14:40:34 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ t_redirect *redir_from_words(t_worddesc *operator,
|
|||
here_doc(spec, STDIN_FILENO, app), 0, NULL, WORD_TOKEN);
|
||||
worddesc_destroy(spec);
|
||||
if (redir->redirectee.filename == NULL)
|
||||
return (redirect_destroy(redir), ft_errno(FT_EERRNO), NULL);
|
||||
return (redirect_destroy(redir), NULL);
|
||||
}
|
||||
else
|
||||
redir->redirectee.filename = specifier;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue