Packet with zero data length (#1659)
If you receive a package with a data length of zero, parsePacket returns 0, but rx_buffer will exist. So if another parsePacket with no read access returns to zeros, there is still data that can be read. This example would not work: https://www.arduino.cc/en/Reference/EthernetUDPParsePacket Also I added a check if rx_buffer exit when you try to flush it.
This commit is contained in:
parent
da798c7db0
commit
f1f8d7e306
@ -221,6 +221,7 @@ int WiFiUDP::parsePacket(){
|
||||
}
|
||||
remote_ip = IPAddress(si_other.sin_addr.s_addr);
|
||||
remote_port = ntohs(si_other.sin_port);
|
||||
if (len == 0) return 0;
|
||||
rx_buffer = new cbuf(len);
|
||||
rx_buffer->write(buf, len);
|
||||
delete[] buf;
|
||||
@ -264,6 +265,7 @@ int WiFiUDP::peek(){
|
||||
}
|
||||
|
||||
void WiFiUDP::flush(){
|
||||
if(!rx_buffer) return;
|
||||
cbuf *b = rx_buffer;
|
||||
rx_buffer = 0;
|
||||
delete b;
|
||||
|
Loading…
Reference in New Issue
Block a user