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 in LineReader #72

Closed
ppwwyyxx opened this Issue Aug 31, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@ppwwyyxx

ppwwyyxx commented Aug 31, 2018

The LineReader has the following logic at https://github.com/ben-strasser/fast-cpp-csv-parser/blob/master/csv.h#L466 to check whether the file ends with "\n":

                        while(buffer[line_end] != '\n' && line_end != data_end){
                                ++line_end;
                        }

                ......

                        if(buffer[line_end] == '\n'){
                                buffer[line_end] = '\0';
                        }else{
                                // some files are missing the newline at the end of the
                                // last line
                                ++data_end;
                                buffer[line_end] = '\0';
                        }

However this is wrong in the following conditions:

  1. there is a missing "\n" at the end of the last line in the file
  2. buffer[line_end] (which contains uninitialized random memory data) happens to be "\n"

In the above case, data_end is not correctly incremented, and cause an assertion error later.

ppwwyyxx added a commit to facebookresearch/House3D that referenced this issue Aug 31, 2018

@ben-strasser

This comment has been minimized.

Owner

ben-strasser commented Sep 30, 2018

I believe this is fixed with the latest commit. If not, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment