From 39fb88f14ed6413b6aafa85fa09f2ad1a3a97e3e Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Fri, 8 Feb 2019 15:29:19 -0800 Subject: [PATCH] Reset size_ to 0 in PinnableSlice::Reset (#4962) Summary: It would avoid bugs if the reused PinnableSlice is not actually reassigned and yet the programmer makes conclusions based on the size of the Slice. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4962 Differential Revision: D14012710 Pulled By: maysamyabandeh fbshipit-source-id: 23f4e173386b5461fd5650f44cde470805f4e816 --- include/rocksdb/slice.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rocksdb/slice.h b/include/rocksdb/slice.h index 9ccbdc51e..4c294c05e 100644 --- a/include/rocksdb/slice.h +++ b/include/rocksdb/slice.h @@ -202,6 +202,7 @@ class PinnableSlice : public Slice, public Cleanable { void Reset() { Cleanable::Reset(); pinned_ = false; + size_ = 0; } inline std::string* GetSelf() { return buf_; } @@ -255,4 +256,4 @@ inline size_t Slice::difference_offset(const Slice& b) const { return off; } -} // namespace rocksdb \ No newline at end of file +} // namespace rocksdb