Skip to content

Commit

Permalink
fix invalid memory access when eol size >1 (wjwwood#220)
Browse files Browse the repository at this point in the history
Co-authored-by: chenguojun <[email protected]>
  • Loading branch information
2 people authored and ccwanggl committed Jun 25, 2023
1 parent f83a1e1 commit de7aa87
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Serial::readline (string &buffer, size_t size, string eol)
if (bytes_read == 0) {
break; // Timeout occured on reading 1 byte
}
if(read_so_far < eol_len) continue;
if (string (reinterpret_cast<const char*>
(buffer_ + read_so_far - eol_len), eol_len) == eol) {
break; // EOL found
Expand Down Expand Up @@ -229,6 +230,7 @@ Serial::readlines (size_t size, string eol)
}
break; // Timeout occured on reading 1 byte
}
if(read_so_far < eol_len) continue;
if (string (reinterpret_cast<const char*>
(buffer_ + read_so_far - eol_len), eol_len) == eol) {
// EOL found
Expand Down

0 comments on commit de7aa87

Please sign in to comment.