From 53c051874bfd15e966e5ce68e17b808e6040bc9f Mon Sep 17 00:00:00 2001 From: LIBA-S Date: Mon, 15 Mar 2021 10:19:11 +0800 Subject: [PATCH] Fix: memory leak when RedisSets destructs --- src/redis_sets.cc | 7 +++++++ src/redis_sets.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/redis_sets.cc b/src/redis_sets.cc index a7efd7c..e168b39 100644 --- a/src/redis_sets.cc +++ b/src/redis_sets.cc @@ -23,6 +23,13 @@ RedisSets::RedisSets(BlackWidow* const bw, const DataType& type) spop_counts_store_->SetCapacity(1000); } +RedisSets::~RedisSets() { + if (spop_counts_store_ != nullptr) { + delete spop_counts_store_; + spop_counts_store_ = nullptr; + } +} + Status RedisSets::Open(const BlackwidowOptions& bw_options, const std::string& db_path) { statistics_store_->SetCapacity(bw_options.statistics_max_size); diff --git a/src/redis_sets.h b/src/redis_sets.h index 98f0286..187de67 100644 --- a/src/redis_sets.h +++ b/src/redis_sets.h @@ -24,7 +24,7 @@ namespace blackwidow { class RedisSets : public Redis { public: RedisSets(BlackWidow* const bw, const DataType& type); - ~RedisSets() = default; + ~RedisSets(); // Common Commands Status Open(const BlackwidowOptions& bw_options,