Closed marimlem closed 3 months ago
another case:
minishell:$ ./minishell minishell:$ exit 255 exit minishell minishell:$ echo $? ==2254684== Invalid read of size 1 ==2254684== at 0x402197: expand_exitstatus (expander.c:57) ==2254684== by 0x4026FE: expander (expander.c:150) ==2254684== by 0x402B37: ltop_dollar (exp_ltop.c:37) ==2254684== by 0x402C71: l_to_p_trans (exp_ltop.c:64) ==2254684== by 0x403B0E: arg_append (command_utils.c:142) ==2254684== by 0x403C63: fill_com_loop (command_utils.c:175) ==2254684== by 0x403D03: fill_com (command_utils.c:210) ==2254684== by 0x403E35: parser (parser.c:12) ==2254684== by 0x404E63: inputparsing (lu_inputparsing.c:37) ==2254684== by 0x401D01: main (main.c:297) ==2254684== Address 0x4b6a535 is 2 bytes after a block of size 3 alloc'd ==2254684== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2254684== by 0x40917F: ft_strdup (ft_strdup.c:26) ==2254684== by 0x402BE1: l_to_p_trans (exp_ltop.c:54) ==2254684== by 0x403B0E: arg_append (command_utils.c:142) ==2254684== by 0x403C63: fill_com_loop (command_utils.c:175) ==2254684== by 0x403D03: fill_com (command_utils.c:210) ==2254684== by 0x403E35: parser (parser.c:12) ==2254684== by 0x404E63: inputparsing (lu_inputparsing.c:37) ==2254684== by 0x401D01: main (main.c:297) ==2254684== 65280
directly after second case:
minishell:$ exit 255 exit minishell ==2254684== ==2254684== HEAP SUMMARY: ==2254684== in use at exit: 208,326 bytes in 232 blocks ==2254684== total heap usage: 883 allocs, 651 frees, 239,602 bytes allocated ==2254684== ==2254684== 6 bytes in 1 blocks are definitely lost in loss record 1 of 67 ==2254684== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2254684== by 0x409260: ft_itoa (ft_itoa.c:61) ==2254684== by 0x401FB3: setup_ext (expander.c:25) ==2254684== by 0x4020A0: expand_exitstatus (expander.c:49) ==2254684== by 0x4026FE: expander (expander.c:150) ==2254684== by 0x402B37: ltop_dollar (exp_ltop.c:37) ==2254684== by 0x402C71: l_to_p_trans (exp_ltop.c:64) ==2254684== by 0x403B0E: arg_append (command_utils.c:142) ==2254684== by 0x403C63: fill_com_loop (command_utils.c:175) ==2254684== by 0x403D03: fill_com (command_utils.c:210) ==2254684== by 0x403E35: parser (parser.c:12) ==2254684== by 0x404E63: inputparsing (lu_inputparsing.c:37) ==2254684== ==2254684== LEAK SUMMARY: ==2254684== definitely lost: 6 bytes in 1 blocks ==2254684== indirectly lost: 0 bytes in 0 blocks ==2254684== possibly lost: 0 bytes in 0 blocks ==2254684== still reachable: 0 bytes in 0 blocks ==2254684== suppressed: 208,320 bytes in 231 blocks
fixed (missing free(code) and two indexing mistakes)
minishell:$ /bin/cat o cat: o: No such file or directory minishell:$ echo $? 256
==2253641== Invalid read of size 1 ==2253641== at 0x402197: expand_exitstatus (expander.c:57) ==2253641== by 0x4026FE: expander (expander.c:150) ==2253641== by 0x402B37: ltop_dollar (exp_ltop.c:37) ==2253641== by 0x402C71: l_to_p_trans (exp_ltop.c:64) ==2253641== by 0x403B0E: arg_append (command_utils.c:142) ==2253641== by 0x403C63: fill_com_loop (command_utils.c:175) ==2253641== by 0x403D03: fill_com (command_utils.c:210) ==2253641== by 0x403E35: parser (parser.c:12) ==2253641== by 0x404E63: inputparsing (lu_inputparsing.c:37) ==2253641== by 0x401D01: main (main.c:297) ==2253641== Address 0x4b6c083 is 0 bytes after a block of size 3 alloc'd ==2253641== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==2253641== by 0x40916F: ft_strdup (ft_strdup.c:26) ==2253641== by 0x402BE1: l_to_p_trans (exp_ltop.c:54) ==2253641== by 0x403B0E: arg_append (command_utils.c:142) ==2253641== by 0x403C63: fill_com_loop (command_utils.c:175) ==2253641== by 0x403D03: fill_com (command_utils.c:210) ==2253641== by 0x403E35: parser (parser.c:12) ==2253641== by 0x404E63: inputparsing (lu_inputparsing.c:37) ==2253641== by 0x401D01: main (main.c:297) ==2253641==