Fix a leak caused by repeating command by no input
authorLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Mon, 19 Feb 2024 21:02:17 +0000 (22:02 +0100)
committerLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Mon, 19 Feb 2024 21:02:17 +0000 (22:02 +0100)
When no command is given, the previous action happens. But this action
did not clean the input string "\n", which caused a leak.

src/main.c

index 7f2e2a446475586f3a2e0c90f13ab3a37d71a1ba..5a0da5589cbf2fbb2472b8c3a892994bc3bcded4 100644 (file)
@@ -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, ' ');