title: Leaks while executing sort
body: <p>I have a file with records and want to sort them out, by calling <code>sort</code> inside my project. Everything seems fine when running the program, but while trying to check for <code>leaks</code> with <code>valgrind</code>, I get a lot of errors. This is the code I use for executing:</p>
  
  <p><code>execlp("sort", "-g", "results", (char*) NULL);</code> </p>
  
  <p><code>results</code> is the file I want sorted out.</p>
  
  <p>And there are the errors.</p>
  
  <pre><code>==27691== 
  ==27691== HEAP SUMMARY:
  ==27691==     in use at exit: 1,352 bytes in 17 blocks
  ==27691==   total heap usage: 66 allocs, 49 frees, 44,055 bytes allocated
  ==27691== 
  ==27691== 16 bytes in 1 blocks are definitely lost in loss record 1 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4110C8: ??? (in /usr/bin/sort)
  ==27691==    by 0x402FFD: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== 64 bytes in 1 blocks are indirectly lost in loss record 2 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4110C8: ??? (in /usr/bin/sort)
  ==27691==    by 0x40D33C: ??? (in /usr/bin/sort)
  ==27691==    by 0x4046A2: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== 88 bytes in 12 blocks are still reachable in loss record 3 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4110C8: ??? (in /usr/bin/sort)
  ==27691==    by 0x402D66: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== 128 bytes in 1 blocks are still reachable in loss record 4 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x411125: ??? (in /usr/bin/sort)
  ==27691==    by 0x405D89: ??? (in /usr/bin/sort)
  ==27691==    by 0x4043C0: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== 1,024 bytes in 1 blocks are indirectly lost in loss record 5 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4110C8: ??? (in /usr/bin/sort)
  ==27691==    by 0x4046D4: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== 1,120 (32 direct, 1,088 indirect) bytes in 1 blocks are definitely lost in loss record 6 of 6
  ==27691==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==27691==    by 0x4110C8: ??? (in /usr/bin/sort)
  ==27691==    by 0x40D313: ??? (in /usr/bin/sort)
  ==27691==    by 0x4046A2: ??? (in /usr/bin/sort)
  ==27691==    by 0x507782F: (below main) (libc-start.c:291)
  ==27691== 
  ==27691== LEAK SUMMARY:
  ==27691==    definitely lost: 48 bytes in 2 blocks
  ==27691==    indirectly lost: 1,088 bytes in 2 blocks
  ==27691==      possibly lost: 0 bytes in 0 blocks
  ==27691==    still reachable: 216 bytes in 13 blocks
  ==27691==         suppressed: 0 bytes in 0 blocks
  ==27691== 
  ==27691== For counts of detected and suppressed errors, rerun with: -v
  ==27691== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
  </code></pre>
  
  <p>Am I doing something wrong? I am not mallocing any pointers and it seems like there errors are out of my reach since they do not appear inside my project.</p>