Fix a memleak
Fix heap overflow in io/cache.c (Thanks @nixerr)