Revert "stack.cc: remove double deletion of stack_handler_"
This reverts commit d0cb756ed536edf5bb2fd23492c22691eab74df8.
Reason for revert: As per updated logic, the instances should be released where created, hence clearing should be done in stack.cc itself.
Change-Id: I49726679d60639b84ec7079513c644116cb9bd6f
diff --git a/system/main/shim/stack.cc b/system/main/shim/stack.cc
index bb8994a..14447d7 100644
--- a/system/main/shim/stack.cc
+++ b/system/main/shim/stack.cc
@@ -169,11 +169,8 @@
log::assert_that(is_running_, "Gd stack not running");
is_running_ = false;
- 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();
- }
+ stack_handler_->Clear();
+
WakelockManager::Get().Acquire();
std::promise<void> promise;
@@ -195,14 +192,7 @@
delete management_handler_;
delete management_thread_;
- 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
+ delete stack_handler_;
stack_handler_ = nullptr;
stack_thread_->Stop();