diff --git a/src/cache.c b/src/cache.c index ba127837997..30c308a72ba 100644 --- a/src/cache.c +++ b/src/cache.c @@ -92,6 +92,12 @@ ts_cache_invalidate(Cache **cache_ptr) return; cache->refcount--; cache_destroy(cache_ptr); + /* + * Even if the cache stays alive due to pins, clear the caller + * pointer so that it cannot be reused. The cache itself will be + * freed with the last pin release (see remove_pin). + */ + *cache_ptr = NULL; } /*