Note that there are some explanatory texts on larger screens.

plurals
  1. POvalgrind reports getpwuid() leaks in c++ with Ubuntu
    primarykey
    data
    text
    <p>I have the following C++ file, pwd01.cpp:</p> <pre><code>#include &lt;pwd.h&gt; #include &lt;iostream&gt; int main() { passwd* pwd = getpwuid(getuid()); } </code></pre> <p>I compile this with the following command:</p> <pre><code>g++ pwd01.cpp -Wall -o pwd01 </code></pre> <p>On Ubuntu 12.04.1 LTS / gcc version 4.6.3, valgrind reports a leak (see below). When I compile the same code with the same command on Mac OS 10.6.8 / gcc version 4.2.1, valgrind reports no leaks. </p> <p>I am aware that I do not need to free passwd* ( <a href="https://stackoverflow.com/questions/160290/should-i-free-pointer-returned-by-getpwuid-in-linux">should I free pointer returned by getpwuid() in Linux?</a> ); so what am I missing? </p> <pre><code>valgrind ./pwd01 ==10618== Memcheck, a memory error detector ==10618== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==10618== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==10618== Command: ./pwd01 ==10618== ==10618== ==10618== HEAP SUMMARY: ==10618== in use at exit: 300 bytes in 11 blocks ==10618== total heap usage: 68 allocs, 57 frees, 10,130 bytes allocated ==10618== ==10618== LEAK SUMMARY: ==10618== definitely lost: 60 bytes in 1 blocks ==10618== indirectly lost: 240 bytes in 10 blocks ==10618== possibly lost: 0 bytes in 0 blocks ==10618== still reachable: 0 bytes in 0 blocks ==10618== suppressed: 0 bytes in 0 blocks ==10618== Rerun with --leak-check=full to see details of leaked memory ==10618== ==10618== For counts of detected and suppressed errors, rerun with: -v ==10618== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload