file I/O-memoryleak-png

Malloc is getting interesting. I know it is not no play-toy.
Was the original example based on casting to void or did I just do that? Or did I create a memory leak? It happen when I change it to write to 1.txt on disk.