Skip to content

Commit 16b1aeb

Browse files
fix(net): Fix IPv4 address construction from ip_addr_t and comparison (#9724) (#9725)
1 parent f1cb6b8 commit 16b1aeb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cores/esp32/IPAddress.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ IPAddress &IPAddress::operator=(const IPAddress &address) {
266266
}
267267

268268
bool IPAddress::operator==(const IPAddress &addr) const {
269-
return (addr._type == _type) && (memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
269+
return (addr._type == _type) && (_type == IPType::IPv4 ? addr._address.dword[IPADDRESS_V4_DWORD_INDEX] == _address.dword[IPADDRESS_V4_DWORD_INDEX] : memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
270270
}
271271

272272
bool IPAddress::operator==(const uint8_t *addr) const {
@@ -395,6 +395,7 @@ IPAddress &IPAddress::from_ip_addr_t(const ip_addr_t *addr) {
395395
#endif /* LWIP_IPV6_SCOPES */
396396
} else {
397397
_type = IPv4;
398+
memset(_address.bytes, 0, sizeof(_address.bytes));
398399
_address.dword[IPADDRESS_V4_DWORD_INDEX] = addr->u_addr.ip4.addr;
399400
}
400401
return *this;

0 commit comments

Comments
 (0)