diff --git a/testing/dart/paragraph_builder_test.dart b/testing/dart/paragraph_builder_test.dart index 0743825f8e29b..d84a8e17c5f66 100644 --- a/testing/dart/paragraph_builder_test.dart +++ b/testing/dart/paragraph_builder_test.dart @@ -17,4 +17,11 @@ void main() { expect(paragraph.width, isNonZero); expect(paragraph.height, isNonZero); }); + + test('PushStyle should not segfault after build()', () { + final ParagraphBuilder paragraphBuilder = + ParagraphBuilder(ParagraphStyle()); + paragraphBuilder.build(); + paragraphBuilder.pushStyle(TextStyle()); + }); } diff --git a/third_party/txt/src/txt/paragraph_builder.cc b/third_party/txt/src/txt/paragraph_builder.cc index 1a34b367a2226..cd9d1591499d3 100644 --- a/third_party/txt/src/txt/paragraph_builder.cc +++ b/third_party/txt/src/txt/paragraph_builder.cc @@ -84,6 +84,7 @@ std::unique_ptr ParagraphBuilder::Build() { paragraph->SetText(std::move(text_), std::move(runs_)); paragraph->SetParagraphStyle(paragraph_style_); paragraph->SetFontCollection(font_collection_); + SetParagraphStyle(paragraph_style_); return paragraph; }