Skip to content

Commit 743caed

Browse files
committed
nullptr checks missing in linked list traversal.
1 parent c61b70d commit 743caed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libraries/ESP8266WiFi/src/include/UdpContext.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class UdpContext
222222
}
223223

224224
bool isValidOffset(const size_t pos) const {
225-
return (pos <= _rx_buf->tot_len);
225+
return (_rx_buf && pos <= _rx_buf->tot_len);
226226
}
227227

228228
netif* getInputNetif() const
@@ -264,7 +264,7 @@ class UdpContext
264264

265265
auto deleteme = _rx_buf;
266266

267-
while(_rx_buf->len != _rx_buf->tot_len)
267+
while(_rx_buf->len != _rx_buf->tot_len && _rx_buf->next)
268268
_rx_buf = _rx_buf->next;
269269

270270
_rx_buf = _rx_buf->next;
@@ -292,7 +292,7 @@ class UdpContext
292292

293293
// this rx_buf is not nullptr by construction,
294294
// ref'ing it to prevent release from the below pbuf_free(deleteme)
295-
pbuf_ref(_rx_buf);
295+
if (_rx_buf) pbuf_ref(_rx_buf);
296296
}
297297
pbuf_free(deleteme);
298298

@@ -466,7 +466,7 @@ class UdpContext
466466
void _consume(size_t size)
467467
{
468468
_rx_buf_offset += size;
469-
if (_rx_buf_offset > _rx_buf->tot_len) {
469+
if (_rx_buf && _rx_buf_offset > _rx_buf->tot_len) {
470470
_rx_buf_offset = _rx_buf->tot_len;
471471
}
472472
}

0 commit comments

Comments
 (0)