From 5c5de6fa271e02342f8f3009b8961939d572c4d3 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Fri, 3 Feb 2023 10:43:16 -0600 Subject: [PATCH 1/2] workaround --- strings/base_implements.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strings/base_implements.h b/strings/base_implements.h index 80a69faa7..56db92678 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -1190,14 +1190,14 @@ namespace winrt::impl return decode_weak_ref(count_or_pointer)->get_source(); } - com_ptr weak_ref; - *weak_ref.put() = new (std::nothrow) weak_ref_t(get_unknown(), static_cast(count_or_pointer)); + void* raw_weak_ref = new (std::nothrow) weak_ref_t(get_unknown(), static_cast(count_or_pointer)); - if (!weak_ref) + if (!raw_weak_ref) { return nullptr; } + com_ptr weak_ref(raw_weak_ref, take_ownership_from_abi); uintptr_t const encoding = encode_weak_ref(weak_ref.get()); while (true) From bdcbfd3f3e7146a4a059936844ffa5a27efd6387 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Mon, 6 Feb 2023 09:14:57 -0600 Subject: [PATCH 2/2] simpler --- strings/base_implements.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/strings/base_implements.h b/strings/base_implements.h index 56db92678..e545b2a57 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -1190,14 +1190,13 @@ namespace winrt::impl return decode_weak_ref(count_or_pointer)->get_source(); } - void* raw_weak_ref = new (std::nothrow) weak_ref_t(get_unknown(), static_cast(count_or_pointer)); + com_ptr weak_ref(new (std::nothrow) weak_ref_t(get_unknown(), static_cast(count_or_pointer)), take_ownership_from_abi); - if (!raw_weak_ref) + if (!weak_ref) { return nullptr; } - com_ptr weak_ref(raw_weak_ref, take_ownership_from_abi); uintptr_t const encoding = encode_weak_ref(weak_ref.get()); while (true)