Corrected a garbage-value error reported by Clang.
Corrected several convoluted chains in cache.c by which either null pointers might be dereferenced, or by which a pointer might be referenced after being freed.  These were reported by Clang static analysis.