[scudo][tests] Pass read-only vector by reference
authorDominic Chen <ddchen@apple.com>
Wed, 16 Mar 2022 20:48:20 +0000 (13:48 -0700)
committerDominic Chen <ddchen@apple.com>
Thu, 17 Mar 2022 17:17:36 +0000 (10:17 -0700)
Differential Revision: https://reviews.llvm.org/D121850

compiler-rt/lib/scudo/standalone/tests/primary_test.cpp
compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp

index 3179ed5..283e297 100644 (file)
@@ -207,7 +207,7 @@ SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryIterate) {
     V.push_back(std::make_pair(ClassId, P));
   }
   scudo::uptr Found = 0;
-  auto Lambda = [V, &Found](scudo::uptr Block) {
+  auto Lambda = [&V, &Found](scudo::uptr Block) {
     for (const auto &Pair : V) {
       if (Pair.second == reinterpret_cast<void *>(Block))
         Found++;
index a7df3d9..e656466 100644 (file)
@@ -153,7 +153,7 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
   const scudo::uptr PageSize = scudo::getPageSizeCached();
   for (scudo::uptr I = 0; I < 32U; I++)
     V.push_back(Allocator->allocate(Options, (std::rand() % 16) * PageSize));
-  auto Lambda = [V](scudo::uptr Block) {
+  auto Lambda = [&V](scudo::uptr Block) {
     EXPECT_NE(std::find(V.begin(), V.end(), reinterpret_cast<void *>(Block)),
               V.end());
   };