Fix invalid-read to freed memory in ttl-iterator

Summary: value function in ttl-iterator was returning string which would have been freed before its usage as a slice. Thanks valgrind!

Test Plan: valgrind ./ttl_test

Reviewers: dhruba, haobo, sheki, vamsi

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D10635
main
Mayank Agarwal 12 years ago
parent d786b25e2d
commit 37e97b1297
  1. 4
      utilities/ttl/db_ttl.cc

@ -54,7 +54,9 @@ class TtlIterator : public Iterator {
Slice value() const { Slice value() const {
assert(iter_->value().size() >= (unsigned)ts_len_); assert(iter_->value().size() >= (unsigned)ts_len_);
return std::string(iter_->value().data(), iter_->value().size() - ts_len_); Slice trimmed_value = iter_->value();
trimmed_value.size_ -= ts_len_;
return trimmed_value;
} }
Status status() const { Status status() const {

Loading…
Cancel
Save