1
0
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:
Chenchen 2021-06-11 05:49:29 +08:00 committed by GitHub
parent cbcca7c837
commit 9e331e7977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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