Skip to content

nullptr check missing in linked list traversal (introduced in PR#7036) #7128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libraries/ESP8266WiFi/src/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class UdpContext
}

bool isValidOffset(const size_t pos) const {
return (pos <= _rx_buf->tot_len);
return (_rx_buf && pos <= _rx_buf->tot_len);
}

netif* getInputNetif() const
Expand Down Expand Up @@ -264,7 +264,7 @@ class UdpContext

auto deleteme = _rx_buf;

while(_rx_buf->len != _rx_buf->tot_len)
while(_rx_buf->len != _rx_buf->tot_len && _rx_buf->next)
_rx_buf = _rx_buf->next;

_rx_buf = _rx_buf->next;
Expand Down Expand Up @@ -292,7 +292,7 @@ class UdpContext

// this rx_buf is not nullptr by construction,
// ref'ing it to prevent release from the below pbuf_free(deleteme)
pbuf_ref(_rx_buf);
if (_rx_buf) pbuf_ref(_rx_buf);
}
pbuf_free(deleteme);

Expand Down Expand Up @@ -466,7 +466,7 @@ class UdpContext
void _consume(size_t size)
{
_rx_buf_offset += size;
if (_rx_buf_offset > _rx_buf->tot_len) {
if (_rx_buf && _rx_buf_offset > _rx_buf->tot_len) {
_rx_buf_offset = _rx_buf->tot_len;
}
}
Expand Down