diff options
author | 2025-03-10 16:08:32 -0700 | |
---|---|---|
committer | 2025-03-10 16:08:32 -0700 | |
commit | e8f580b89d92bc94a34e0215bf4ac45992d7ffb1 (patch) | |
tree | eb3097f9e28af275f44c26c7fb42bafff0a763da | |
parent | d3ab34b581bae9eb2553685186d85e03419a5f52 (diff) | |
parent | f749ebc9d045216d107b0e19dc00ae5bc95b30cf (diff) |
Merge "stack.cc: remove double deletion of stack_handler_" into main am: ab39bae1d4 am: f749ebc9d0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3533050
Change-Id: Ic6b923e5fc37f5d8b4799ffca2cb10e01eb0076a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | system/main/shim/stack.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/system/main/shim/stack.cc b/system/main/shim/stack.cc index 14447d75b3..bb8994aee0 100644 --- a/system/main/shim/stack.cc +++ b/system/main/shim/stack.cc @@ -169,8 +169,11 @@ void Stack::Stop() { log::assert_that(is_running_, "Gd stack not running"); is_running_ = false; - stack_handler_->Clear(); - + if (!com::android::bluetooth::flags::same_handler_for_all_modules()) { + // Clear the handler only if the flag is not defined, otherwise it will be cleared by the + // registry + stack_handler_->Clear(); + } WakelockManager::Get().Acquire(); std::promise<void> promise; @@ -192,7 +195,14 @@ void Stack::Stop() { delete management_handler_; delete management_thread_; - delete stack_handler_; + if (!com::android::bluetooth::flags::same_handler_for_all_modules()) { + // delete the handler only if the flag is not defined, otherwise it will be deleted by the + // registry + delete stack_handler_; + } + + // stack_handler_ is already deleted by the registry in handle_shut_down, just set it to nullptr + // to avoid any potential use-after-free stack_handler_ = nullptr; stack_thread_->Stop(); |