From 4d7558cc6c579019a42ec76991d2e531edfd27a0 Mon Sep 17 00:00:00 2001 From: Andrii Borziak Date: Thu, 15 Feb 2024 10:30:17 -0800 Subject: [PATCH] Fixed use after free bug in generated code --- .../CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs b/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs index a0c75000..638afc8b 100644 --- a/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs +++ b/source/UIDataCodeGen/CodeGen/Cppwinrt/CppwinrtInstantiatorGenerator.cs @@ -1210,7 +1210,7 @@ void WriteEnsureImageLoadingStarted(CodeBuilder builder) builder.WriteLine("if (!m_isImageLoadingStarted)"); builder.OpenScope(); builder.WriteLine("m_isImageLoadingStarted = true;"); - builder.WriteLine($"TypedEventHandler eventHandler{{ this, &{_sourceClassName}::HandleLoadCompleted }};"); + builder.WriteLine($"TypedEventHandler eventHandler{{ get_weak(), &{_sourceClassName}::HandleLoadCompleted }};"); foreach (var n in SourceInfo.LoadedImageSurfaces) {