mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
fix invalid memory access when eol size >1 (#220)
Co-authored-by: chenguojun <chenguojun@yogorobot.com>
This commit is contained in:
parent
cbcca7c837
commit
9e331e7977
@ -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
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user