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

buffer: Fix underlying memory reused wrongly #3

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
1 participant
@Xuanwo

Xuanwo commented Jun 3, 2018

Currently, we return the underlying bytes directly in buffer.Bytes().
But the underlying bytes could be reused after buffer.Free() and
before we actually read it. This commit will fix this issue by made a
copy before returning.

ref: https://blog.golang.org/go-slices-usage-and-internals

Signed-off-by: Xuanwo xuanwo.cn@gmail.com

buffer: Fix underlying memory reused wrongly
Currently, we return the underlying bytes directly in `buffer.Bytes()`.
But the underlying bytes could be reused after `buffer.Free()` and
before we actually read it. This commit will fix this issue by made a
copy before returning.

ref: https://blog.golang.org/go-slices-usage-and-internals

Signed-off-by: Xuanwo <xuanwo.cn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment