WebP goes through a different process, where the decoder dumps it to raw and then the RawImagePlugin takes a hack at it.  

The libtiff function requires the entire image in one call, and within the decode function, if there's an error, it callsTIFFClose. There's some mucking about to make the decode happen in one chunk.

Gif appears to be a custom decoder, there's no malloc or free in it. I think all the allocations are in the context, which will get cleaned up when it goes out of scope. 
 
Png appears to be a python implementation.