The code documents an unexplained crash in libpng, but was also leaking filehandles...