Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions libdash/libdash/source/helpers/BlockStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,23 @@ bool BlockStream::BlockQueuePeekBytes (uint8_t *data, uint32_t len
while(pos < len)
{
block = this->blockqueue.at(cnt);
if((offset + len - pos) < (block->len))
if (offset >= block->len)
{
memcpy(data + pos, block->data + offset, len - pos - offset);
return true;
offset-= block->len;
}
else
{
memcpy(data + pos, block->data + offset, block->len - offset);
pos += block->len;
if((offset + len - pos) < (block->len))
{
memcpy(data + pos, block->data + offset, len - pos - offset);
return true;
}
else
{
memcpy(data + pos, block->data + offset, block->len - offset);
pos += (block->len - offset);
offset = 0;
}
}

cnt++;
Expand Down Expand Up @@ -287,4 +295,4 @@ BlockStream* BlockStream::GetBlocks (uint64_t len)
}

return blocks;
}
}