1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Fix WiFiUDP::peek return value when buffer is empty (#1796)

This commit is contained in:
Ivan Grokhotkov 2016-03-24 01:21:10 +03:00
parent 213914e1ce
commit 19e97bfe15
2 changed files with 4 additions and 4 deletions

View File

@ -236,7 +236,7 @@ int WiFiUDP::read(unsigned char* buffer, size_t len)
int WiFiUDP::peek() int WiFiUDP::peek()
{ {
if (!_ctx) if (!_ctx)
return 0; return -1;
return _ctx->peek(); return _ctx->peek();
} }

View File

@ -190,7 +190,7 @@ public:
int read() int read()
{ {
if (!_rx_buf || _rx_buf->len == _rx_buf_offset) if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
return -1; return -1;
char c = reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset]; char c = reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
@ -215,8 +215,8 @@ public:
char peek() char peek()
{ {
if (!_rx_buf) if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
return 0; return -1;
return reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset]; return reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
} }