diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 85c348327dc..a4301ad0e09 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -182,7 +182,7 @@ class WiFiClientSocketHandle { } }; -WiFiClient::WiFiClient():_connected(false),_timeout(WIFI_CLIENT_DEF_CONN_TIMEOUT_MS),next(NULL) +WiFiClient::WiFiClient():_rxBuffer(nullptr),_connected(false),_timeout(WIFI_CLIENT_DEF_CONN_TIMEOUT_MS),next(NULL) { } @@ -508,7 +508,9 @@ int WiFiClient::available() // Though flushing means to send all pending data, // seems that in Arduino it also means to clear RX void WiFiClient::flush() { - _rxBuffer->flush(); + if (_rxBuffer != nullptr) { + _rxBuffer->flush(); + } } uint8_t WiFiClient::connected()