From 440ee21267454d6472aea18cf044f350acff6534 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 6 Nov 2024 13:13:46 -0800 Subject: [PATCH] [Impeller] Do not capture the temporary ImpellerMapping struct pointer when storing release callbacks in libImpeller (flutter/engine#56411) Fixes https://github.com/flutter/flutter/issues/158285 --- .../src/flutter/impeller/toolkit/interop/impeller.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/impeller/toolkit/interop/impeller.cc b/engine/src/flutter/impeller/toolkit/interop/impeller.cc index 31135453b09..03999398268 100644 --- a/engine/src/flutter/impeller/toolkit/interop/impeller.cc +++ b/engine/src/flutter/impeller/toolkit/interop/impeller.cc @@ -494,8 +494,9 @@ ImpellerTexture ImpellerTextureCreateWithContentsNew( auto wrapped_contents = std::make_shared( contents->data, // data ptr contents->length, // data length - [contents, contents_on_release_user_data](auto, auto) { - contents->on_release(contents_on_release_user_data); + [on_release = contents->on_release, contents_on_release_user_data]( + auto, auto) { + on_release(contents_on_release_user_data); } // release callback ); if (!texture->SetContents(std::move(wrapped_contents))) { @@ -1147,8 +1148,9 @@ bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context, auto wrapped_contents = std::make_unique( contents->data, // data ptr contents->length, // data length - [contents, contents_on_release_user_data](auto, auto) { - contents->on_release(contents_on_release_user_data); + [on_release = contents->on_release, contents_on_release_user_data](auto, + auto) { + on_release(contents_on_release_user_data); } // release callback ); return GetPeer(context)->RegisterFont(std::move(wrapped_contents),