Fix WriteBatchWithIndex address use after scope error
Summary: Fix use after scope error caught by ASAN. Closes https://github.com/facebook/rocksdb/pull/2228 Differential Revision: D4968028 Pulled By: yiwu-arbug fbshipit-source-id: a2a266c98634237494ab4fb2d666bc938127aeb2
This commit is contained in:
parent
ebbce5b10d
commit
71acb4c122
@ -150,7 +150,7 @@ WriteBatchWithIndexInternal::Result WriteBatchWithIndexInternal::GetFromBatch(
|
||||
// TODO(agiardullo): consider adding support for reverse iteration
|
||||
iter->Seek(key);
|
||||
while (iter->Valid()) {
|
||||
const WriteEntry& entry = iter->Entry();
|
||||
const WriteEntry entry = iter->Entry();
|
||||
if (cmp->CompareKey(cf_id, entry.key, key) != 0) {
|
||||
break;
|
||||
}
|
||||
@ -169,9 +169,9 @@ WriteBatchWithIndexInternal::Result WriteBatchWithIndexInternal::GetFromBatch(
|
||||
iter->Prev();
|
||||
}
|
||||
|
||||
const Slice* entry_value = nullptr;
|
||||
Slice entry_value;
|
||||
while (iter->Valid()) {
|
||||
const WriteEntry& entry = iter->Entry();
|
||||
const WriteEntry entry = iter->Entry();
|
||||
if (cmp->CompareKey(cf_id, entry.key, key) != 0) {
|
||||
// Unexpected error or we've reached a different next key
|
||||
break;
|
||||
@ -180,7 +180,7 @@ WriteBatchWithIndexInternal::Result WriteBatchWithIndexInternal::GetFromBatch(
|
||||
switch (entry.type) {
|
||||
case kPutRecord: {
|
||||
result = WriteBatchWithIndexInternal::Result::kFound;
|
||||
entry_value = &entry.value;
|
||||
entry_value = entry.value;
|
||||
break;
|
||||
}
|
||||
case kMergeRecord: {
|
||||
@ -242,7 +242,7 @@ WriteBatchWithIndexInternal::Result WriteBatchWithIndexInternal::GetFromBatch(
|
||||
Logger* logger = immuable_db_options.info_log.get();
|
||||
|
||||
if (merge_operator) {
|
||||
*s = MergeHelper::TimedFullMerge(merge_operator, key, entry_value,
|
||||
*s = MergeHelper::TimedFullMerge(merge_operator, key, &entry_value,
|
||||
merge_context->GetOperands(), value,
|
||||
logger, statistics, env);
|
||||
} else {
|
||||
@ -255,7 +255,7 @@ WriteBatchWithIndexInternal::Result WriteBatchWithIndexInternal::GetFromBatch(
|
||||
}
|
||||
} else { // nothing to merge
|
||||
if (result == WriteBatchWithIndexInternal::Result::kFound) { // PUT
|
||||
value->assign(entry_value->data(), entry_value->size());
|
||||
value->assign(entry_value.data(), entry_value.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user