Skip to content
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

这里的缓冲区未更新是否为bug #2

Open
nk-akun opened this issue Mar 25, 2020 · 0 comments
Open

这里的缓冲区未更新是否为bug #2

nk-akun opened this issue Mar 25, 2020 · 0 comments

Comments

@nk-akun
Copy link

nk-akun commented Mar 25, 2020

func (b *Reader) ReadFull(n int) ([]byte, error) {

func (b *Reader) ReadFull(n int) ([]byte, error) {
	//return b.buf[]
	if b.err != nil || n == 0 {
		return nil, b.err
	}
	var buf = b.slice.Make(n)
	if _, err := io.ReadFull(bytes.NewReader(b.buf[b.rpos:]), buf); err != nil {
		return nil, err
	}
	b.rpos += n
	return buf, nil
}

这里每次从缓冲区读取长度为n的buf,但未考虑b.buf读完的情况,详细看了几遍感觉还是有问题。

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

No branches or pull requests

1 participant