Skip to content

Commit 7e40de2

Browse files
authored
Fixes #4435 - WiFiClient improperly treats zero data available for read as an error (#4448)
1 parent 1287c52 commit 7e40de2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: libraries/WiFi/src/WiFiClient.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class WiFiClientRxBuffer {
105105

106106
int read(uint8_t * dst, size_t len){
107107
if(!dst || !len || (_pos == _fill && !fillBuffer())){
108-
return -1;
108+
return _failed ? -1 : 0;
109109
}
110110
size_t a = _fill - _pos;
111111
if(len <= a || ((len - a) <= (_size - _fill) && fillBuffer() >= (len - a))){
@@ -346,6 +346,9 @@ int WiFiClient::read()
346346
if(res < 0) {
347347
return res;
348348
}
349+
if (res == 0) { // No data available.
350+
return -1;
351+
}
349352
return data;
350353
}
351354

0 commit comments

Comments
 (0)