Skip to content

Commit c99d6c6

Browse files
authored
Fix some stack-use-after-scopes found by ASan (flutter#28147)
Fixes for Embedder and RefCounted tests.
1 parent a818cb1 commit c99d6c6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

fml/memory/ref_counted_unittest.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,15 @@ TEST(RefCountedTest, SelfAssignment) {
472472

473473
TEST(RefCountedTest, Swap) {
474474
MyClass* created1 = nullptr;
475-
bool was_destroyed1 = false;
475+
static bool was_destroyed1;
476+
was_destroyed1 = false;
476477
RefPtr<MyClass> r1(MakeRefCounted<MyClass>(&created1, &was_destroyed1));
477478
EXPECT_TRUE(created1);
478479
EXPECT_EQ(created1, r1.get());
479480

480481
MyClass* created2 = nullptr;
481-
bool was_destroyed2 = false;
482+
static bool was_destroyed2;
483+
was_destroyed2 = false;
482484
RefPtr<MyClass> r2(MakeRefCounted<MyClass>(&created2, &was_destroyed2));
483485
EXPECT_TRUE(created2);
484486
EXPECT_EQ(created2, r2.get());

shell/platform/embedder/tests/embedder_unittests_gl.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,8 @@ TEST_F(EmbedderTest,
20182018

20192019
constexpr size_t frames_expected = 10;
20202020
fml::CountDownLatch frame_latch(frames_expected);
2021-
size_t frames_seen = 0;
2021+
static size_t frames_seen;
2022+
frames_seen = 0;
20222023
context.AddNativeCallback("SignalNativeTest",
20232024
CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
20242025
frames_seen++;
@@ -2056,7 +2057,8 @@ TEST_F(EmbedderTest,
20562057

20572058
constexpr size_t frames_expected = 10;
20582059
fml::CountDownLatch frame_latch(frames_expected);
2059-
size_t frames_seen = 0;
2060+
static size_t frames_seen;
2061+
frames_seen = 0;
20602062
context.AddNativeCallback("SignalNativeTest",
20612063
CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
20622064
frames_seen++;

0 commit comments

Comments
 (0)