Fix leaking memory in case of a broken xcf file
Before this commit nearly all memory was leaked in case of a faulty xcf
file. This commit tries to patch at least some of them.
Known issues: flatten.c:556
To test if it works correctly, I'd need to test it on broken files.
Before all of the xcf patches in case of a broken file Krita
silently crashed (or rather, closed suddenly with a xcf error code)
because of the way xcf library was written. Having memory leaks
can be considered an improvement over the dataloss crash.