btm_iso_test: Fix memory leak in test code
==2701005==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x562ccc86cc9d in operator new(unsigned long) out/stage2/out/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
#1 0x562ccc8c7f18 in IsoManagerTest_RegisterCallbacks_Test::TestBody() system/bt/stack/test/btm_iso_test.cc:498:33
#2 0x562cccc11a73 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) external/googletest/googletest/src/gtest.cc
#3 0x562cccc11a73 in testing::Test::Run() external/googletest/googletest/src/gtest.cc:2682:5
#4 0x562cccc14689 in testing::TestInfo::Run() external/googletest/googletest/src/gtest.cc:2861:11
#5 0x562cccc15e56 in testing::TestSuite::Run() external/googletest/googletest/src/gtest.cc:3015:28
#6 0x562cccc4d031 in testing::internal::UnitTestImpl::RunAllTests() external/googletest/googletest/src/gtest.cc:5855:44
#7 0x562cccc4ba5e in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) external/googletest/googletest/src/gtest.cc
#8 0x562cccc4ba5e in testing::UnitTest::Run() external/googletest/googletest/src/gtest.cc:5438:10
#9 0x562cccbecf57 in RUN_ALL_TESTS() external/googletest/googletest/include/gtest/gtest.h:2490:46
#10 0x562cccbecf57 in main external/googletest/googletest/src/gtest_main.cc:52:10
#11 0x7f942614dcb1 in __libc_start_main csu/../csu/libc-start.c:314:16
Direct leak of 224 byte(s) in 1 object(s) allocated from:
#0 0x562ccc86cc9d in operator new(unsigned long) out/stage2/out/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
#1 0x562ccc8c7dce in IsoManagerTest_RegisterCallbacks_Test::TestBody() system/bt/stack/test/btm_iso_test.cc:497:33
#2 0x562cccc11a73 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) external/googletest/googletest/src/gtest.cc
#3 0x562cccc11a73 in testing::Test::Run() external/googletest/googletest/src/gtest.cc:2682:5
#4 0x562cccc14689 in testing::TestInfo::Run() external/googletest/googletest/src/gtest.cc:2861:11
#5 0x562cccc15e56 in testing::TestSuite::Run() external/googletest/googletest/src/gtest.cc:3015:28
#6 0x562cccc4d031 in testing::internal::UnitTestImpl::RunAllTests() external/googletest/googletest/src/gtest.cc:5855:44
#7 0x562cccc4ba5e in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) external/googletest/googletest/src/gtest.cc
#8 0x562cccc4ba5e in testing::UnitTest::Run() external/googletest/googletest/src/gtest.cc:5438:10
#9 0x562cccbecf57 in RUN_ALL_TESTS() external/googletest/googletest/include/gtest/gtest.h:2490:46
#10 0x562cccbecf57 in main external/googletest/googletest/src/gtest_main.cc:52:10
#11 0x7f942614dcb1 in __libc_start_main csu/../csu/libc-start.c:314:16
sponsor: jpawlowski
test: test/run_host_unit_tests.py
bug: 150670922
Change-Id: I87423912a72df560087de3dfa8cad1f318d999ac
diff --git a/system/stack/test/btm_iso_test.cc b/system/stack/test/btm_iso_test.cc
index 2444ea1..c44449e 100644
--- a/system/stack/test/btm_iso_test.cc
+++ b/system/stack/test/btm_iso_test.cc
@@ -494,8 +494,8 @@
auto* iso_mgr = IsoManager::GetInstance();
ASSERT_EQ(manager_instance_, iso_mgr);
- iso_mgr->RegisterBigCallbacks(new MockBigCallbacks());
- iso_mgr->RegisterCigCallbacks(new MockCigCallbacks());
+ iso_mgr->RegisterBigCallbacks(big_callbacks_.get());
+ iso_mgr->RegisterCigCallbacks(cig_callbacks_.get());
}
TEST_F(IsoManagerDeathTestNoInit, RegisterNullBigCallbacks) {