From 851ceb570a772d6b53009eee22ec2c21037a8997 Mon Sep 17 00:00:00 2001 From: Jeroen88 Date: Tue, 1 Jan 2019 15:18:24 +0100 Subject: [PATCH 1/3] Fix WiFiClientRxBuffer::fillBuffer() error in handing a negative res from the call to recv() --- libraries/BLE | 2 +- libraries/WiFi/src/WiFiClient.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/BLE b/libraries/BLE index b232e7f5f0e..11a0aa64532 160000 --- a/libraries/BLE +++ b/libraries/BLE @@ -1 +1 @@ -Subproject commit b232e7f5f0e87f36afbc2f4e03a2c49c48dd47bc +Subproject commit 11a0aa645326aed0cb681e86060fe28d4623bc68 diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 5c42cc9da1b..28450c0592c 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -58,6 +58,10 @@ class WiFiClientRxBuffer { { if(!_buffer){ _buffer = (uint8_t *)malloc(_size); + if(!_buffer) { + _failed = true; + return 0; + } } if(_fill && _pos == _fill){ _fill = 0; @@ -67,8 +71,10 @@ class WiFiClientRxBuffer { 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; From 0af48f2ce58ad4ec85a210a733aa483898a0f671 Mon Sep 17 00:00:00 2001 From: Jeroen88 Date: Tue, 1 Jan 2019 16:43:16 +0100 Subject: [PATCH 2/3] Add logging in fillBuffer() if allocation of buffer fails --- libraries/WiFi/src/WiFiClient.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 28450c0592c..8ea6c7afb65 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -59,6 +59,7 @@ class WiFiClientRxBuffer { if(!_buffer){ _buffer = (uint8_t *)malloc(_size); if(!_buffer) { + log_e("Not enough memory to allocate buffer"); _failed = true; return 0; } From 8538ae101f867aced65e1b8aa06ae362e67af165 Mon Sep 17 00:00:00 2001 From: Jeroen88 Date: Wed, 2 Jan 2019 15:37:55 +0100 Subject: [PATCH 3/3] Remove BLE subdirectory --- .gitmodules | 3 --- libraries/BLE | 1 - 2 files changed, 4 deletions(-) delete mode 160000 libraries/BLE diff --git a/.gitmodules b/.gitmodules index eeeb114ee67..c9e5e6fd92e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "libraries/BLE"] - path = libraries/BLE - url = https://github.com/nkolban/ESP32_BLE_Arduino.git [submodule "libraries/AzureIoT"] path = libraries/AzureIoT url = https://github.com/VSChina/ESP32_AzureIoT_Arduino diff --git a/libraries/BLE b/libraries/BLE deleted file mode 160000 index 11a0aa64532..00000000000 --- a/libraries/BLE +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 11a0aa645326aed0cb681e86060fe28d4623bc68