Skip to content

Commit

Permalink
Fix error in PR #2048: if ::available() is called before ::connect() …
Browse files Browse the repository at this point in the history
…_rxBuffer is not initialised (#2155)
  • Loading branch information
Jeroen88 authored and me-no-dev committed Dec 6, 2018
1 parent 7280370 commit bff9f0b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ int WiFiClient::peek()

int WiFiClient::available()
{
if(!_rxBuffer)
{
return 0;
}
int res = _rxBuffer->available();
if(_rxBuffer->failed()) {
log_e("%d", errno);
Expand Down

1 comment on commit bff9f0b

@everslick
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it legal to call available() before connect()? And if it is, why does the same logic not apply to read(), write(), ... ? all those functions potentially access rxBuffer before it exists.

Please sign in to comment.