stream is re-defined which misplaces size of item data.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Follow-up fix for #12788.
This commit is contained in:
hy che 2017-03-30 08:53:16 +00:00 committed by Adrien Destugues
parent eff44d2fee
commit d1012e4522

View File

@ -166,17 +166,17 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,
&& stream->entries[i].key.Type() == key.Type()) {
TRACE("Find() found %" B_PRIu32 " %" B_PRIu32 "\n",
stream->entries[i].Offset(), stream->entries[i].Size());
if (_value != NULL) {
*_value = malloc(stream->entries[i].Size());
uint32 totalOffset = stream->entries[i].Offset() + sizeof(btrfs_header);
key.SetOffset(stream->entries[i].key.Offset());
if ((fVolume->BlockSize() - totalOffset % fVolume->BlockSize())
>= stream->entries[i].Size()) {
//If there is enough space for *_value
stream = (btrfs_stream*)cached.SetTo(physical
+ totalOffset / fVolume->BlockSize());
memcpy(*_value, ((uint8 *)&stream->header
memcpy(*_value, ((uint8 *)cached.SetTo(physical
+ totalOffset / fVolume->BlockSize())
+ totalOffset % fVolume->BlockSize()),
stream->entries[i].Size());
} else {
@ -184,6 +184,8 @@ BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,
* fVolume->BlockSize() + totalOffset,
*_value, stream->entries[i].Size());
}
key.SetOffset(stream->entries[i].key.Offset());
if (_size != NULL)
*_size = stream->entries[i].Size();
}