From f37e96e73bff7b45363dd84d8a659a5ad440476c Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 29 Feb 2024 19:03:04 -0800 Subject: [PATCH] [Impeller] Fix leak of rectangle packer in typographer tests (flutter/engine#51113) --- engine/src/flutter/impeller/typographer/rectangle_packer.cc | 5 +++-- engine/src/flutter/impeller/typographer/rectangle_packer.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/impeller/typographer/rectangle_packer.cc b/engine/src/flutter/impeller/typographer/rectangle_packer.cc index b80faa7d4e..bebecf69ae 100644 --- a/engine/src/flutter/impeller/typographer/rectangle_packer.cc +++ b/engine/src/flutter/impeller/typographer/rectangle_packer.cc @@ -166,8 +166,9 @@ void SkylineRectanglePacker::addSkylineLevel(int skylineIndex, } } -RectanglePacker* RectanglePacker::Factory(int width, int height) { - return new SkylineRectanglePacker(width, height); +std::unique_ptr RectanglePacker::Factory(int width, + int height) { + return std::make_unique(width, height); } } // namespace impeller diff --git a/engine/src/flutter/impeller/typographer/rectangle_packer.h b/engine/src/flutter/impeller/typographer/rectangle_packer.h index 9213cae678..48365a515f 100644 --- a/engine/src/flutter/impeller/typographer/rectangle_packer.h +++ b/engine/src/flutter/impeller/typographer/rectangle_packer.h @@ -27,7 +27,7 @@ class RectanglePacker { //---------------------------------------------------------------------------- /// @brief Return an empty packer with area specified by width and height. /// - static RectanglePacker* Factory(int width, int height); + static std::unique_ptr Factory(int width, int height); virtual ~RectanglePacker() {}