Skip to content

Commit

Permalink
SocketWrapper MbedClient stopped client read() crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Jun 16, 2024
1 parent 0108ded commit b94442f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/SocketWrapper/src/MbedClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ int arduino::MbedClient::available() {
}

int arduino::MbedClient::read() {
if (sock == nullptr)
return -1;
mutex->lock();
if (!available()) {
mutex->unlock();
Expand All @@ -241,12 +243,14 @@ int arduino::MbedClient::read() {
}

int arduino::MbedClient::read(uint8_t *data, size_t len) {
if (sock == nullptr)
return 0;
mutex->lock();
int avail = available();

if (!avail) {
mutex->unlock();
return -1;
return 0;
}

if ((int)len > avail) {
Expand Down

0 comments on commit b94442f

Please sign in to comment.