From 9547ee774830ab624e1d3e2ef57f101f1812ab0f Mon Sep 17 00:00:00 2001 From: raheelh Date: Sun, 21 Feb 2016 21:32:36 -0600 Subject: [PATCH] Bug fix in WiFiClient::peek() The function should return error if ServerDrv::getData() failed. --- libraries/WiFi/src/WiFiClient.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index eb8e6af1dec..7dda5883113 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -131,12 +131,14 @@ int WiFiClient::read(uint8_t* buf, size_t size) { } int WiFiClient::peek() { - uint8_t b; - if (!available()) - return -1; + uint8_t b; + if (!available()) + return -1; - ServerDrv::getData(_sock, &b, 1); - return b; + if (!ServerDrv::getData(_sock, &b, 1)) + return -1; + + return b; } void WiFiClient::flush() {