Make checker free memory of get_next_line on error
authorLukas Jiriste <ljiriste@student.42prague.com>
Tue, 5 Mar 2024 11:47:08 +0000 (12:47 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Tue, 5 Mar 2024 11:47:08 +0000 (12:47 +0100)
Without this get_next_line frees its memory on EOF,
but when invalid command is entered, EOF never comes.

src/checker.c

index eff49a5e9ad34016ae5cfde0e71756c7bd1d5ce9..3ed7d1628f4bd3683b8d97835d333db2c1603bcc 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/01/24 10:31:06 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/03/05 09:40:36 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/03/05 12:46:19 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -75,6 +75,7 @@ static int    interpret(t_stacks *s)
                if (command_parse(input, &command))
                {
                        free(input);
+                       get_next_line(-1);
                        return (1);
                }
                execute(command, s);