Skip to content

Commit 851ceb5

Browse files
author
Jeroen88
committed
Fix WiFiClientRxBuffer::fillBuffer() error in handing a negative res from the call to recv()
1 parent 229d9b7 commit 851ceb5

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

libraries/BLE

libraries/WiFi/src/WiFiClient.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class WiFiClientRxBuffer {
5858
{
5959
if(!_buffer){
6060
_buffer = (uint8_t *)malloc(_size);
61+
if(!_buffer) {
62+
_failed = true;
63+
return 0;
64+
}
6165
}
6266
if(_fill && _pos == _fill){
6367
_fill = 0;
@@ -67,8 +71,10 @@ class WiFiClientRxBuffer {
6771
return 0;
6872
}
6973
int res = recv(_fd, _buffer + _fill, _size - _fill, MSG_DONTWAIT);
70-
if(res < 0 && errno != EWOULDBLOCK) {
71-
_failed = true;
74+
if(res < 0) {
75+
if(errno != EWOULDBLOCK) {
76+
_failed = true;
77+
}
7278
return 0;
7379
}
7480
_fill += res;

0 commit comments

Comments
 (0)