From a0525e9688383d21b95c9e43ca31c47135075d8e Mon Sep 17 00:00:00 2001 From: yuvaln-s1 Date: Tue, 20 Dec 2022 15:50:37 +0200 Subject: [PATCH] Fix object usage after move in make_delegate_with_shared_state The function make_delegate_with_shared_state (from strings/base_coroutine_foundation.h) uses on object after it was moved. 'd' is moved using std::move and then it's passed to get_abi. The usage of 'd' after it was moved it undefined. --- strings/base_coroutine_foundation.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/base_coroutine_foundation.h b/strings/base_coroutine_foundation.h index 2f8297d0b..6afeff607 100644 --- a/strings/base_coroutine_foundation.h +++ b/strings/base_coroutine_foundation.h @@ -42,7 +42,8 @@ namespace winrt::impl std::pair make_delegate_with_shared_state(H&& handler) { auto d = make_delegate(std::forward(handler)); - return { std::move(d), reinterpret_cast*>(get_abi(d)) }; + auto abi = reinterpret_cast*>(get_abi(d)); + return { std::move(d), abi }; } template