Skip to content

Commit 3072ac8

Browse files
authored
Merge pull request ben-strasser#123 from mhfrantz/master
Safer buffer index check in LineReader::next_line
2 parents 75600d0 + 352c366 commit 3072ac8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

csv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ namespace io{
465465
}
466466

467467
int line_end = data_begin;
468-
while(buffer[line_end] != '\n' && line_end != data_end){
468+
while(line_end != data_end && buffer[line_end] != '\n'){
469469
++line_end;
470470
}
471471

@@ -476,7 +476,7 @@ namespace io{
476476
throw err;
477477
}
478478

479-
if(buffer[line_end] == '\n' && line_end != data_end){
479+
if(line_end != data_end && buffer[line_end] == '\n'){
480480
buffer[line_end] = '\0';
481481
}else{
482482
// some files are missing the newline at the end of the

0 commit comments

Comments
 (0)