Fixes #4435 - WiFiClient improperly treats zero data available for read as an error (#4448)

This commit is contained in:
M Hotchin 2020-10-27 03:01:41 -07:00 committed by GitHub
parent 1287c52933
commit 7e40de226f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,7 +105,7 @@ public:
int read(uint8_t * dst, size_t len){
if(!dst || !len || (_pos == _fill && !fillBuffer())){
return -1;
return _failed ? -1 : 0;
}
size_t a = _fill - _pos;
if(len <= a || ((len - a) <= (_size - _fill) && fillBuffer() >= (len - a))){
@ -346,6 +346,9 @@ int WiFiClient::read()
if(res < 0) {
return res;
}
if (res == 0) { // No data available.
return -1;
}
return data;
}