瀏覽代碼

Merge pull request #206 from FrankBoesing/patch-1

fix limit checks readString/readStringUntil
main
Paul Stoffregen 7 年之前
父節點
當前提交
4bcebfd636
共有 1 個檔案被更改,包括 4 行新增28 行删除
  1. +4
    -28
      teensy3/Stream.cpp

+ 4
- 28
teensy3/Stream.cpp 查看文件

@@ -256,7 +256,7 @@ size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
String Stream::readString(size_t max)
{
String str;
size_t length = str.length();
size_t length = 0;
while (length < max) {
int c = timedRead();
if (c < 0) {
@@ -265,6 +265,7 @@ String Stream::readString(size_t max)
}
if (c == 0) break;
str += (char)c;
length++;
}
return str;
}
@@ -272,7 +273,7 @@ String Stream::readString(size_t max)
String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = str.length();
size_t length = 0;
while (length < max) {
int c = timedRead();
if (c < 0) {
@@ -281,32 +282,7 @@ String Stream::readStringUntil(char terminator, size_t max)
}
if (c == 0 || c == terminator) break;
str += (char)c;
length++;
}
return str;
}



























Loading…
取消
儲存