Fix stack-use-after-scope issues in WeaveWiFiSetupTest test cases. This CL fixes a stack-use-after-scope issue, detected by ASAN, in the WeaveWiFiSetupTest.OfflineLongTimeWithNoSsid and WeaveWiFiSetupTest.OfflineLongTimeWithSsid test cases, where the 'time_stamp' variable on the stack is captured by reference for used in lambdas. The 'time_stamp' variable should thus be defined in a scope that survives until after lambdas are executed. BUG=chromium:717228 TEST=`USE='clang asan' emerge-$BOARD libweave` Change-Id: Ib1013a5f020d6f233d45537fdf6f32ce2f3d8e56 Reviewed-on: https://weave-review.googlesource.com/9970 Reviewed-by: Eric Caruso <ejcaruso@google.com>
diff --git a/src/weave_unittest.cc b/src/weave_unittest.cc index fba9a8a..d7855df 100644 --- a/src/weave_unittest.cc +++ b/src/weave_unittest.cc
@@ -474,9 +474,9 @@ NotifyNetworkChanged(provider::Network::State::kOnline, base::TimeDelta::FromHours(15)); + auto time_stamp = task_runner_.GetClock()->Now(); { InSequence s; - auto time_stamp = task_runner_.GetClock()->Now(); EXPECT_CALL(wifi_, StartAccessPoint(MatchesRegex("TEST_NAME.*prv"))) .WillOnce(InvokeWithoutArgs([this, &time_stamp]() { @@ -505,9 +505,9 @@ NotifyNetworkChanged(provider::Network::State::kOnline, base::TimeDelta::FromHours(15)); + auto time_stamp = task_runner_.GetClock()->Now(); { InSequence s; - auto time_stamp = task_runner_.GetClock()->Now(); for (size_t i = 0; i < 10; ++i) { EXPECT_CALL(wifi_, StartAccessPoint(MatchesRegex("TEST_NAME.*prv"))) .WillOnce(InvokeWithoutArgs([this, &time_stamp]() {