biralavor / 42_minishell

minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros
MIT License
3 stars 0 forks source link

remove memory leak - 12 bytes at command manager #235

Closed biralavor closed 2 months ago

biralavor commented 2 months ago
valgrind --leak-check=full --track-origins=yes --track-fds=yes --show-reachable=yes --suppressions=readline.sup ./minishell
==90547== Memcheck, a memory error detector
==90547== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==90547== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==90547== Command: ./minishell
==90547== 
<<< Born Again (mini) SHell >>>$ ps

Total lst size: 1
Printing the List Now  
|---|--------------|--------------|------------|------------|------------|----------|
|idx| token lexeme |  token type  |    prev    |    self    |    next    | nxt char |
|---|--------------|--------------|------------|------------|------------|----------|
| 0 |           ps |         WORD |      (nil) |  0x4b23d60 |      (nil) |         |
|---|--------------|--------------|------------|------------|------------|----------|

    PID TTY          TIME CMD
  41255 pts/0    00:00:02 zsh
  90494 pts/0    00:00:00 make
  90547 pts/0    00:00:01 memcheck-amd64-
  90548 pts/0    00:00:00 ps
<<< Born Again (mini) SHell >>>$ exit

Total lst size: 1
Printing the List Now  
|---|--------------|--------------|------------|------------|------------|----------|
|idx| token lexeme |  token type  |    prev    |    self    |    next    | nxt char |
|---|--------------|--------------|------------|------------|------------|----------|
| 0 |         exit |         WORD |      (nil) |  0x4b287f0 |      (nil) |         |
|---|--------------|--------------|------------|------------|------------|----------|

==90547== 
==90547== FILE DESCRIPTORS: 0 open at exit.
==90547== 
==90547== HEAP SUMMARY:
==90547==     in use at exit: 204,693 bytes in 217 blocks
==90547==   total heap usage: 961 allocs, 744 frees, 242,273 bytes allocated
==90547== 
==90547== 12 bytes in 1 blocks are definitely lost in loss record 4 of 60
==90547==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==90547==    by 0x407E3A: ft_strjoin (ft_strjoin.c:27)
==90547==    by 0x408B1C: ft_merge_strings (ft_merge_strings.c:19)
==90547==    by 0x405F45: testing_all_paths_with_cmd (33.execve_utils.c:79)
==90547==    by 0x405ACA: lookup_cmd_path (32.execve.c:58)
==90547==    by 0x405B26: command_manager (32.execve.c:76)
==90547==    by 0x405C17: execute (32.execve.c:104)
==90547==    by 0x405D19: tree_execution (32.execve.c:132)
==90547==    by 0x401B1D: loop_routine (02.check_userinput.c:51)
==90547==    by 0x401A78: main (01.simple_main.c:71)
==90547== 
==90547== LEAK SUMMARY:
==90547==    definitely lost: 12 bytes in 1 blocks
==90547==    indirectly lost: 0 bytes in 0 blocks
==90547==      possibly lost: 0 bytes in 0 blocks
==90547==    still reachable: 0 bytes in 0 blocks
==90547==         suppressed: 204,681 bytes in 216 blocks
==90547== 
==90547== For lists of detected and suppressed errors, rerun with: -s
==90547== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
[14:08:09] umeneses:42_minishell git:(231-remove-memory-leak-from-command_manager*) $
biralavor commented 2 months ago

This issue was done at #255