From a297643f2e327a8bc7061bfc838fdf11935a2cf2 Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Thu, 11 Aug 2016 23:34:19 -0700 Subject: [PATCH] Fix valgrind memory leak --- db/forward_iterator.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/db/forward_iterator.cc b/db/forward_iterator.cc index f66e1f0af..92b5ab25e 100644 --- a/db/forward_iterator.cc +++ b/db/forward_iterator.cc @@ -42,6 +42,15 @@ class LevelIterator : public InternalIterator { file_iter_(nullptr), pinned_iters_mgr_(nullptr) {} + ~LevelIterator() { + // Reset current pointer + if (pinned_iters_mgr_ && pinned_iters_mgr_->PinningEnabled()) { + pinned_iters_mgr_->PinIterator(file_iter_); + } else { + delete file_iter_; + } + } + void SetFileIndex(uint32_t file_index) { assert(file_index < files_.size()); if (file_index != file_index_) {