Fullstop000/wickdb

BlockIterator could cause UB

Closed this issue · 1 comments

Blocks #37
Relate to #24

wickdb/src/sstable/table.rs

Lines 181 to 185 in 8a87a80

let mut block_iter = self.block_reader(cmp, data_block_handle, options)?;
block_iter.seek(key);
if block_iter.valid() {
return Ok(Some((block_iter.key(), block_iter.value())));
}

As block_iter.key() returns an owned Slice which represents the key field in block_iter, UB occurs after block_iter is dropped.

Temporarily solved by lengthening the lifetime of block_iter