From: Lukáš Jiřiště Date: Mon, 19 Feb 2024 21:02:17 +0000 (+0100) Subject: Fix a leak caused by repeating command by no input X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=f2dce97d5915503fc8aa0e8a7b403a69273f68e2;p=FET_sim.git Fix a leak caused by repeating command by no input When no command is given, the previous action happens. But this action did not clean the input string "\n", which caused a leak. --- diff --git a/src/main.c b/src/main.c index 7f2e2a4..5a0da55 100644 --- a/src/main.c +++ b/src/main.c @@ -227,7 +227,10 @@ int get_input(t_input *input, int fd) return (1); } if (str_inp[0] == '\n') + { + free(str_inp); return (1); + } if (str_inp[0] && str_inp[ft_strlen(str_inp) - 1] == '\n') str_inp[ft_strlen(str_inp) - 1] = '\0'; split_inp = ft_split(str_inp, ' ');