title: Valgrind says about "Invalid write" in fclose()
body: <p>I created a stream using fmemopen(). I am closing it with fclose() and freeing the buffer after reading. Valgrind reports about problem at fclose() line:</p>
  
  <pre><code>==9323== Invalid write of size 8
  ==9323==    at 0x52CAE52: _IO_mem_finish (memstream.c:139)
  ==9323==    by 0x52C6A3E: fclose@@GLIBC_2.2.5 (iofclose.c:63)
  ==9323==    by 0x400CB6: main (main.cpp:80)
  ==9323==  Address 0xffefffa80 is just below the stack ptr.  To suppress, 
  use: --workaround-gcc296-bugs=yes
  </code></pre>
  
  <p>What's happening? Maybe fclose() cannot properly close a memory stream? Or maybe valgrind worries without reason and I can ignore that?</p>