From fab06765e47d2c19646f803d190a57f5b2b783f8 Mon Sep 17 00:00:00 2001 From: Juraj Andrassy Date: Sun, 16 Jun 2024 18:16:55 +0200 Subject: [PATCH] SocketWrapper MbedClient stopped client read() crash fix --- libraries/SocketWrapper/src/MbedClient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index 49188df7e..2bb933350 100644 --- a/libraries/SocketWrapper/src/MbedClient.cpp +++ b/libraries/SocketWrapper/src/MbedClient.cpp @@ -229,6 +229,8 @@ int arduino::MbedClient::available() { } int arduino::MbedClient::read() { + if (sock == nullptr) + return -1; mutex->lock(); if (!available()) { mutex->unlock(); @@ -241,6 +243,8 @@ int arduino::MbedClient::read() { } int arduino::MbedClient::read(uint8_t *data, size_t len) { + if (sock == nullptr) + return 0; mutex->lock(); int avail = available();