From 5383511e7d6289e4fe1c055a5a91c87984d1e14c Mon Sep 17 00:00:00 2001 From: Rongqi Sun Date: Fri, 12 Apr 2024 02:34:01 +0000 Subject: [PATCH] test/test_rgw_crypto: free allocated test_in When sanitizer is enabled, unittest__rgw_crypto shows ``` ================================================================= ==136464==ERROR: LeakSanitizer: detected memory leaks Direct leak of 75023 byte(s) in 22 object(s) allocated from: #0 0xaaaabf7fb86c in operator new[](unsigned long) (/root/ceph/build/bin/unittest_rgw_crypto+0x48b86c) (BuildId: 8023dc30820215da92d6d4883620bedd8ac1190d) #1 0xaaaabf81db48 in TestRGWCrypto_verify_Encrypt_Decrypt_Test::TestBody() /root/ceph/src/test/rgw/test_rgw_crypto.cc:780:24 #2 0xaaaabf9018ac in void testing::internal::HandleSehExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) /root/ceph/src/googletest/googletest/src/gtest.cc:2605:10 #3 0xaaaabf8b08a4 in void testing::internal::HandleExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) /root/ceph/src/googletest/googletest/src/gtest.cc:2641:14 #4 0xaaaabf861f88 in testing::Test::Run() /root/ceph/src/googletest/googletest/src/gtest.cc:2680:5 #5 0xaaaabf863ecc in testing::TestInfo::Run() /root/ceph/src/googletest/googletest/src/gtest.cc:2858:11 #6 0xaaaabf8654cc in testing::TestSuite::Run() /root/ceph/src/googletest/googletest/src/gtest.cc:3012:28 #7 0xaaaabf881290 in testing::internal::UnitTestImpl::RunAllTests() /root/ceph/src/googletest/googletest/src/gtest.cc:5723:44 #8 0xaaaabf90b7ac in bool testing::internal::HandleSehExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /root/ceph/src/googletest/googletest/src/gtest.cc:2605:10 #9 0xaaaabf8b7ac0 in bool testing::internal::HandleExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /root/ceph/src/googletest/googletest/src/gtest.cc:2641:14 #10 0xaaaabf880708 in testing::UnitTest::Run() /root/ceph/src/googletest/googletest/src/gtest.cc:5306:10 #11 0xaaaabf823d70 in RUN_ALL_TESTS() /root/ceph/src/googletest/googletest/include/gtest/gtest.h:2486:46 #12 0xaaaabf81f390 in main /root/ceph/src/test/rgw/test_rgw_crypto.cc:822:10 #13 0xffff878673f8 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #14 0xffff878674c8 in __libc_start_main csu/../csu/libc-start.c:392:3 #15 0xaaaabf74d62c in _start (/root/ceph/build/bin/unittest_rgw_crypto+0x3dd62c) (BuildId: 8023dc30820215da92d6d4883620bedd8ac1190d) SUMMARY: AddressSanitizer: 75023 byte(s) leaked in 22 allocation(s). ``` test_in should be freed to address the warning. Signed-off-by: Rongqi Sun --- src/test/rgw/test_rgw_crypto.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/rgw/test_rgw_crypto.cc b/src/test/rgw/test_rgw_crypto.cc index 88104ebefd3de..1c1762ff868d1 100644 --- a/src/test/rgw/test_rgw_crypto.cc +++ b/src/test/rgw/test_rgw_crypto.cc @@ -806,6 +806,7 @@ TEST(TestRGWCrypto, verify_Encrypt_Decrypt) decrypt.flush(); ASSERT_EQ(get_sink.get_sink().length(), test_size); ASSERT_EQ(get_sink.get_sink(), std::string_view((char*)test_in,test_size)); + delete[] test_in; } while (test_size < 20000); }