From 7a19817b90a5e0cab6093313bc6d41faf0cf257b Mon Sep 17 00:00:00 2001 From: yh-sb Date: Sat, 5 Oct 2024 15:48:41 +0300 Subject: [PATCH] Fix clang-tidy error: clang-analyzer-cplusplus.NewDelete It occurs when arg is used after delete. clang-tidy doesn't understand that there is an exception thrown after delete. win_thread.ipp:79:20: error: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete,-warnings-as-errors] 79 | arg->exit_event_ = exit_event_ = ::CreateEventW(0, true, false, 0); --- asio/include/asio/detail/impl/win_thread.ipp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asio/include/asio/detail/impl/win_thread.ipp b/asio/include/asio/detail/impl/win_thread.ipp index 0ebc5db86b..8fb961bcfc 100644 --- a/asio/include/asio/detail/impl/win_thread.ipp +++ b/asio/include/asio/detail/impl/win_thread.ipp @@ -75,6 +75,7 @@ void win_thread::start_thread(func_base* arg, unsigned int stack_size) asio::detail::throw_error(ec, "thread.entry_event"); } + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete) arg->exit_event_ = exit_event_ = ::CreateEventW(0, true, false, 0); if (!exit_event_) { @@ -86,6 +87,7 @@ void win_thread::start_thread(func_base* arg, unsigned int stack_size) } unsigned int thread_id = 0; + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete) thread_ = reinterpret_cast(::_beginthreadex(0, stack_size, win_thread_function, arg, 0, &thread_id)); if (!thread_)