diff --git a/strings/base_array.h b/strings/base_array.h index d29bee883..73914e624 100644 --- a/strings/base_array.h +++ b/strings/base_array.h @@ -382,12 +382,11 @@ WINRT_EXPORT namespace winrt std::memset(&result, 0, sizeof(result)); result.first = this->size(); result.second = *reinterpret_cast*>(this); - std::memset(this, 0, sizeof(com_array)); #else std::pair> result(this->size(), *reinterpret_cast*>(this)); +#endif this->m_data = nullptr; this->m_size = 0; -#endif return result; } diff --git a/test/old_tests/UnitTests/array.cpp b/test/old_tests/UnitTests/array.cpp index 2b5952004..d494d951c 100644 --- a/test/old_tests/UnitTests/array.cpp +++ b/test/old_tests/UnitTests/array.cpp @@ -1079,6 +1079,19 @@ TEST_CASE("com_array,move") REQUIRE(b.empty()); } +TEST_CASE("com_array,detach") +{ + com_array a{ 1, 2, 3 }; + auto detached = detach_abi(a); + com_array b(detached.second, detached.first, take_ownership_from_abi); + + REQUIRE(a.empty()); + REQUIRE(3 == b.size()); + REQUIRE(b[0] == 1); + REQUIRE(b[1] == 2); + REQUIRE(b[2] == 3); +} + // // Now some tests covering producing and consuming arrays //