Fix potential memory leak on cache purge.

Signed-off-by: Chris Sanders <zidane@outlook.com>