From 8f08a86bd382eb79fa225a5afccb63638774eb5a Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Fri, 13 Aug 2021 13:37:36 -0700 Subject: [PATCH 1/4] Fix stack-use-after-scope in RefCountedTest.Swap --- fml/memory/ref_counted_unittest.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fml/memory/ref_counted_unittest.cc b/fml/memory/ref_counted_unittest.cc index 4cefb8b5ff5f9..75685cce0144a 100644 --- a/fml/memory/ref_counted_unittest.cc +++ b/fml/memory/ref_counted_unittest.cc @@ -472,13 +472,15 @@ TEST(RefCountedTest, SelfAssignment) { TEST(RefCountedTest, Swap) { MyClass* created1 = nullptr; - bool was_destroyed1 = false; + static bool was_destroyed1; + was_destroyed1 = false; RefPtr r1(MakeRefCounted(&created1, &was_destroyed1)); EXPECT_TRUE(created1); EXPECT_EQ(created1, r1.get()); MyClass* created2 = nullptr; - bool was_destroyed2 = false; + static bool was_destroyed2; + was_destroyed2 = false; RefPtr r2(MakeRefCounted(&created2, &was_destroyed2)); EXPECT_TRUE(created2); EXPECT_EQ(created2, r2.get()); From 9474594d19189218f58aa7379b42e9a37dcad772 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Fri, 13 Aug 2021 14:39:42 -0700 Subject: [PATCH 2/4] Fix stack-use-after-scope in EmbedderTest.PushingMutlipleFrames* --- shell/platform/embedder/tests/embedder_unittests_gl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/platform/embedder/tests/embedder_unittests_gl.cc b/shell/platform/embedder/tests/embedder_unittests_gl.cc index d15baadf8bf6c..3c837429f2456 100644 --- a/shell/platform/embedder/tests/embedder_unittests_gl.cc +++ b/shell/platform/embedder/tests/embedder_unittests_gl.cc @@ -2018,7 +2018,8 @@ TEST_F(EmbedderTest, constexpr size_t frames_expected = 10; fml::CountDownLatch frame_latch(frames_expected); - size_t frames_seen = 0; + static size_t frames_seen; + frames_seen = 0; context.AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { frames_seen++; @@ -2056,7 +2057,8 @@ TEST_F(EmbedderTest, constexpr size_t frames_expected = 10; fml::CountDownLatch frame_latch(frames_expected); - size_t frames_seen = 0; + static size_t frames_seen; + frames_seen = 0; context.AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { frames_seen++; From 5542c04fdebc5815f7ce0b2c9c150c0a506dbf18 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 17 Aug 2021 12:20:57 -0700 Subject: [PATCH 3/4] Fix stack-use-after-scope in ParagraphTest.GetWordBoundaryParagraph --- third_party/txt/src/txt/paragraph_txt.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/txt/src/txt/paragraph_txt.cc b/third_party/txt/src/txt/paragraph_txt.cc index ec14079fc62a1..7135f85b348ec 100644 --- a/third_party/txt/src/txt/paragraph_txt.cc +++ b/third_party/txt/src/txt/paragraph_txt.cc @@ -1992,7 +1992,8 @@ Paragraph::Range ParagraphTxt::GetWordBoundary(size_t offset) { return Range(0, 0); } - word_breaker_->setText(icu::UnicodeString(false, text_.data(), text_.size())); + auto unicode_text = icu::UnicodeString(false, text_.data(), text_.size()); + word_breaker_->setText(unicode_text); int32_t prev_boundary = word_breaker_->preceding(offset + 1); int32_t next_boundary = word_breaker_->next(); From 08010adaeb8cb82747d531884cf329ded5c1e4c2 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 17 Aug 2021 14:26:33 -0700 Subject: [PATCH 4/4] Revert "Fix stack-use-after-scope in ParagraphTest.GetWordBoundaryParagraph" This reverts commit 5542c04fdebc5815f7ce0b2c9c150c0a506dbf18. --- third_party/txt/src/txt/paragraph_txt.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/third_party/txt/src/txt/paragraph_txt.cc b/third_party/txt/src/txt/paragraph_txt.cc index 7135f85b348ec..ec14079fc62a1 100644 --- a/third_party/txt/src/txt/paragraph_txt.cc +++ b/third_party/txt/src/txt/paragraph_txt.cc @@ -1992,8 +1992,7 @@ Paragraph::Range ParagraphTxt::GetWordBoundary(size_t offset) { return Range(0, 0); } - auto unicode_text = icu::UnicodeString(false, text_.data(), text_.size()); - word_breaker_->setText(unicode_text); + word_breaker_->setText(icu::UnicodeString(false, text_.data(), text_.size())); int32_t prev_boundary = word_breaker_->preceding(offset + 1); int32_t next_boundary = word_breaker_->next();