From 685912d07f1bff8e98d432d379425a6db57f393e Mon Sep 17 00:00:00 2001 From: Yi Wu Date: Thu, 5 Apr 2018 11:49:42 -0700 Subject: [PATCH] Clock cache should check if deleter is nullptr before calling it Summary: Clock cache should check if deleter is nullptr before calling it. Closes https://github.com/facebook/rocksdb/pull/3677 Differential Revision: D7493602 Pulled By: yiwu-arbug fbshipit-source-id: 4f94b188d2baf2cbc7c0d5da30fea1215a683de4 --- cache/clock_cache.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cache/clock_cache.cc b/cache/clock_cache.cc index 8c26f7a9c..f57859830 100644 --- a/cache/clock_cache.cc +++ b/cache/clock_cache.cc @@ -367,7 +367,9 @@ ClockCacheShard::~ClockCacheShard() { for (auto& handle : list_) { uint32_t flags = handle.flags.load(std::memory_order_relaxed); if (InCache(flags) || CountRefs(flags) > 0) { - (*handle.deleter)(handle.key, handle.value); + if (handle.deleter != nullptr) { + (*handle.deleter)(handle.key, handle.value); + } delete[] handle.key.data(); } }