fix: free value returned by readline
This commit is contained in:
parent
b2f6d4b058
commit
67bf858a49
2 changed files with 5 additions and 3 deletions
1
dev/TODO
1
dev/TODO
|
@ -10,7 +10,6 @@
|
|||
- exit (with no options)
|
||||
- fix
|
||||
- empty variables aren't freed
|
||||
- need to free value returned by readline
|
||||
- the builtins should get all arguments and check if they're good
|
||||
- command `echo "hello` with unclosed quotes
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 13:47:40 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/06/25 13:06:57 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/06/25 15:28:41 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -57,7 +57,8 @@ static int heredoc(t_memclass mc, int *readfd, const char *eof)
|
|||
{
|
||||
const t_memclass mc_in = mem_subclass(fatal_error, mc);
|
||||
int outpipe[2];
|
||||
t_const_string line;
|
||||
char *line;
|
||||
char *to_free;
|
||||
const t_const_string eof_line = str_join(fatal_error, mc_in, eof, "\n");
|
||||
|
||||
if (pipe(outpipe) == -1)
|
||||
|
@ -66,12 +67,14 @@ static int heredoc(t_memclass mc, int *readfd, const char *eof)
|
|||
while (true)
|
||||
{
|
||||
line = cool_readline("\e[38;5;33m( 'o')> \e[0m");
|
||||
to_free = line;
|
||||
if (!line)
|
||||
line = "";
|
||||
if (str_eq(line, eof) || str_eq(line, eof_line))
|
||||
break ;
|
||||
print_str(err_remember, outpipe[1], line);
|
||||
print_str(err_remember, outpipe[1], "\n");
|
||||
free(to_free);
|
||||
if (err_get())
|
||||
return (minishell_error("errno"), errno);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue