Skip to content

Fix infinite loop in MemReader::read_until. #12106

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

Merged
merged 2 commits into from
Feb 9, 2014

Conversation

qpliu
Copy link
Contributor

@qpliu qpliu commented Feb 8, 2014

I don't know if anything depends on MemReader::fill returning an empty slice instead of EndOfFile, but I'm pretty sure that MemReader::read_until should not go into an infinite loop.

@sfackler
Copy link
Member

sfackler commented Feb 8, 2014

It actually looks like all implementations of Buffer return an empty buffer on EOF. @alexcrichton: what's the intended API here?

@alexcrichton
Copy link
Member

This looks like the correct fix to me. I intended it to not be an error if fill returned a slice of length 0. The BufferedReader implementation can pass through 0-length reads because of this.

This was definitely in error though, because you have genuinely hit an error at the end of a MemReader or BufReader

@sfackler
Copy link
Member

sfackler commented Feb 8, 2014

Cool. @qpliu could you implement the same fix for BufReader and BufferedReader?

@alexcrichton
Copy link
Member

I think that BufferedReader should be ok (may need some tests though) because the underlying reader will eventually return EOF. BufReader, however, likely needs this fix.

bors added a commit that referenced this pull request Feb 9, 2014
I don't know if anything depends on MemReader::fill returning an empty slice instead of EndOfFile, but I'm pretty sure that MemReader::read_until should not go into an infinite loop.
@bors bors closed this Feb 9, 2014
@bors bors merged commit 71c88e7 into rust-lang:master Feb 9, 2014
@qpliu qpliu deleted the memreader-fill-eof branch February 9, 2014 07:01
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
…=Veykril

feat: provide Self in record literal completion

close rust-lang#12106
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.

4 participants