Skip to content

Commit b94442f

Browse files
committed
SocketWrapper MbedClient stopped client read() crash fix
1 parent 0108ded commit b94442f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: libraries/SocketWrapper/src/MbedClient.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ int arduino::MbedClient::available() {
229229
}
230230

231231
int arduino::MbedClient::read() {
232+
if (sock == nullptr)
233+
return -1;
232234
mutex->lock();
233235
if (!available()) {
234236
mutex->unlock();
@@ -241,12 +243,14 @@ int arduino::MbedClient::read() {
241243
}
242244

243245
int arduino::MbedClient::read(uint8_t *data, size_t len) {
246+
if (sock == nullptr)
247+
return 0;
244248
mutex->lock();
245249
int avail = available();
246250

247251
if (!avail) {
248252
mutex->unlock();
249-
return -1;
253+
return 0;
250254
}
251255

252256
if ((int)len > avail) {

0 commit comments

Comments
 (0)