Fix memory leak in cache_add(). TODO: add gotos to fix more of these.