From b0ac9477df2a92044cf08a08a709c4549270cbd6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 24 Apr 2026 03:28:24 -0500 Subject: [PATCH] [web_server_idf] Widen NewDeleteLeaks NOLINT over start_session_main_loop_ The previous narrow NOLINT only wrapped the sorting_groups JSON loop. Now that the function is invoked through an extra call layer (loop() -> adopt_pending_sessions_main_loop_ -> start_session_main_loop_), clang-analyzer traces a leak path through ws->get_config_json() as well -- also a false positive inside ArduinoJson's VariantData. Move the NOLINTBEGIN/NOLINTEND to bracket the entire function body. --- esphome/components/web_server_idf/web_server_idf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/web_server_idf/web_server_idf.cpp b/esphome/components/web_server_idf/web_server_idf.cpp index 77b1e745ec..5abb9db627 100644 --- a/esphome/components/web_server_idf/web_server_idf.cpp +++ b/esphome/components/web_server_idf/web_server_idf.cpp @@ -589,6 +589,7 @@ AsyncEventSourceResponse::AsyncEventSourceResponse(const AsyncWebServerRequest * httpd_sess_set_send_override(this->hd_, this->fd_.load(), nonblocking_send); } +// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson void AsyncEventSourceResponse::start_session_main_loop_() { auto *ws = this->web_server_; @@ -598,13 +599,11 @@ void AsyncEventSourceResponse::start_session_main_loop_() { #ifdef USE_WEBSERVER_SORTING for (auto &group : ws->sorting_groups_) { - // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson json::JsonBuilder builder; JsonObject root = builder.root(); root["name"] = group.second.name; root["sorting_weight"] = group.second.weight; message = builder.serialize(); - // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) // a (very) large number of these should be able to be queued initially without defer // since the only thing in the send buffer at this point is the initial ping/config @@ -614,6 +613,7 @@ void AsyncEventSourceResponse::start_session_main_loop_() { this->entities_iterator_.begin(ws->include_internal_); } +// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) void AsyncEventSourceResponse::destroy(void *ptr) { auto *rsp = static_cast(ptr);