TS-1475: Fix use after free in cache-scan plugin. Coverity #1021658