From 00e69a28bc5b12f6dda4675781ec5cb679b901ac Mon Sep 17 00:00:00 2001 From: Jeroen88 Date: Wed, 2 Jan 2019 16:44:17 +0100 Subject: [PATCH] Redo PR #2259 because I messed up my local git (#2263) --- libraries/WiFi/src/WiFiClient.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 5c42cc9d..8ea6c7af 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -58,6 +58,11 @@ private: { if(!_buffer){ _buffer = (uint8_t *)malloc(_size); + if(!_buffer) { + log_e("Not enough memory to allocate buffer"); + _failed = true; + return 0; + } } if(_fill && _pos == _fill){ _fill = 0; @@ -67,8 +72,10 @@ private: return 0; } int res = recv(_fd, _buffer + _fill, _size - _fill, MSG_DONTWAIT); - if(res < 0 && errno != EWOULDBLOCK) { - _failed = true; + if(res < 0) { + if(errno != EWOULDBLOCK) { + _failed = true; + } return 0; } _fill += res;