Check socket type before accessing pcb.tcp union member

Move the NETCONN_TCP type check before the pcb.tcp null check
to avoid reading the wrong union member on non-TCP sockets.
This commit is contained in:
J. Nick Koston
2026-03-10 22:39:36 -10:00
parent ef9f34b9ab
commit a9c2be5193
+3 -1
View File
@@ -218,10 +218,12 @@ void esphome_lwip_hook_socket(struct lwip_sock *sock) {
}
bool esphome_lwip_set_nodelay(struct lwip_sock *sock, bool enable) {
if (sock == NULL || sock->conn == NULL || sock->conn->pcb.tcp == NULL)
if (sock == NULL || sock->conn == NULL)
return false;
if (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_TCP)
return false;
if (sock->conn->pcb.tcp == NULL)
return false;
if (enable) {
tcp_nagle_disable(sock->conn->pcb.tcp);
} else {