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
This commit is contained in:
Mayank Agarwal 2013-05-03 14:25:12 -07:00
parent d786b25e2d
commit 37e97b1297

View File

@ -54,7 +54,9 @@ class TtlIterator : public Iterator {
Slice value() const {
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 {