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
main
Maysam Yabandeh 5 years ago committed by Facebook Github Bot
parent 1a761e6a6c
commit 39fb88f14e
  1. 3
      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
} // namespace rocksdb

Loading…
Cancel
Save