Skip to content

Fix the wrong chunk header size due to clear the whole buffer by mistake #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

zhenlineo
Copy link
Contributor

@zhenlineo zhenlineo commented Apr 23, 2016

The situation where the issue arises:

When IN_CHUNK,

if (bytesToRead < readableBytesLeftInBuffer)
{
    read readable bytes left in buffer
    clear the buffer as we read all bytes already // wrong!!!
    ...
}

The problem is that there could be more bytes that do not belong to readable bytes left in the buffer, such as (part of) next chunk header!!
So instead of buffer.clear, use buffer.compact would solve this issue.
Tests should be needed to accept this PR.

The situation where the issue arises:

When IN_CHUNK,
if (bytesToRead < readableBytesLeftInBuffer)
{
	read readable bytes left in buffer
	clear the buffer as we read all bytes already // wrong!!!
	...
}

The problem is that there could be more bytes that do not belong to readable bytes left in the buffer, such as (part of) next chunk header!!
So instead of buffer.clear, use buffer.compact would solve this issue.
Tests should be needed to accept this PR.
@pontusmelke pontusmelke mentioned this pull request Apr 25, 2016
@zhenlineo zhenlineo closed this May 3, 2016
@zhenlineo zhenlineo deleted the 1.0-fix-missing-byte branch May 3, 2016 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant