This is some C code to reproduce a bug with fmemopen(), and possibly some other functions, on glibc-2.22. I does not seem to happen in Linux distributions that use glibc-2.21.
To reproduce type:
make test
You'll need GNU make, gcc, and perl 5.
Tested with glibc-2.22-9.mga6, gcc-5.2.1-0.20151103.1.mga6 on Mageia Linux x86-64 v6 (Cauldron). Also tested with the vanilla glibc. This seems to work fine on Debian x86-64 Testing and on Fedora x86-64 22.
There are some #if
statements in the code that can toggle a different behaviour. As can be seen when printing to stdout
or to a file, everything is working fine.