From 14255f930cce04c1683596690425ea97e9802052 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 30 Sep 2026 22:42:00 +0200 Subject: [PATCH] Keep the null check on global_captive_portal for the static analyzer --- esphome/components/wifi/wifi_component.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 423b85c9fa..73e79d1b31 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -2234,11 +2234,12 @@ bool WiFiComponent::is_ap_portal_active_() { return this->is_captive_portal_active_(); } -// Neither global needs a null check: codegen always instantiates the component when its -// define is set, and the constructor assigns the global. +// global_web_server needs no null check: codegen always instantiates WebServer when +// USE_WEBSERVER_CAPTIVE is defined, and the constructor assigns the global. void WiFiComponent::start_ap_portal_() { #ifdef USE_CAPTIVE_PORTAL - captive_portal::global_captive_portal->start(); + if (captive_portal::global_captive_portal != nullptr) + captive_portal::global_captive_portal->start(); #endif #ifdef USE_WEBSERVER_CAPTIVE web_server::global_web_server->start_captive();