marimlem / minishell

0 stars 0 forks source link

invalid free: subshell -> exit 255 #28

Closed marimlem closed 3 months ago

marimlem commented 3 months ago

minishell:$ ./minishell minishell:$ exit 255 exit minishell (invalid free here) minishell:$ echo $? 65280

==2253641== Invalid free() / delete / delete[] / realloc() ==2253641== at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2253641== by 0x401487: com_lst_del (main.c:48) ==2253641== by 0x40163F: free_n_clean (main.c:99) ==2253641== by 0x401D7E: main (main.c:313) ==2253641== Address 0x4b6dc20 is 0 bytes inside a block of size 10 free'd ==2253641== at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2253641== by 0x40143C: com_lst_del (main.c:42) ==2253641== by 0x40163F: free_n_clean (main.c:99) ==2253641== by 0x401D7E: main (main.c:313) ==2253641== Block was alloc'd at ==2253641== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2253641== by 0x40916F: ft_strdup (ft_strdup.c:26) ==2253641== by 0x4066DF: relative_path (execute2.c:365) ==2253641== by 0x406817: setup_cmdpath (execute2.c:393) ==2253641== by 0x4068C8: executor2 (execute2.c:418) ==2253641== by 0x401D73: main (main.c:311) ==2253641==

marimlem commented 3 months ago

fixed by strduping properly in relative_path (only occurred when using ./minishell)