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

Potential infinite loop in MetricSearcher::FindOffset(xxx) #27

Closed
sczyh30 opened this issue Jul 29, 2020 · 0 comments · Fixed by #28
Closed

Potential infinite loop in MetricSearcher::FindOffset(xxx) #27

sczyh30 opened this issue Jul 29, 2020 · 0 comments · Fixed by #28
Labels
kind/bug Something isn't working

Comments

@sczyh30
Copy link
Member

sczyh30 commented Jul 29, 2020

Issue Description

Type: bug report

Describe what happened (or what feature you want)

while (!istream.eof()) { ... } may cause infinite loop in MetricSearcher::FindOffset(xxx):

while (!in.eof()) {
in >> second >> tmp_offset;
if (second < begin_second) {
last_pos_.offset_in_index = in.tellg();
} else {
offset = tmp_offset;
break;
}
}

The eof() will return false even if the failbit or badbit is true. Refer: https://stackoverflow.com/questions/13079900/file-i-o-infinite-loop-c-eof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant