allocate self freshly, do not use the stack variable

with tmpfile and fmemopen