From a9c2be51936e0e6ee0edc66533f8370f28d5d220 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 10 Mar 2026 22:39:36 -1000 Subject: [PATCH] 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. --- esphome/core/lwip_fast_select.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/core/lwip_fast_select.c b/esphome/core/lwip_fast_select.c index ca693494670..a695fa396bc 100644 --- a/esphome/core/lwip_fast_select.c +++ b/esphome/core/lwip_fast_select.c @@ -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 {