From 2be4b090991866216d1113122ae679da167414ef Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Tue, 25 Jun 2024 13:40:50 -0700 Subject: [PATCH] Fix ASan report about alloc/dealloc mismatch when compiled with C++23 (#633) Co-authored-by: Alexey Milovidov --- crt/aws-lc | 2 +- include/aws/crt/StlAllocator.h | 4 ++++ source/io/HostResolver.cpp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crt/aws-lc b/crt/aws-lc index 4e54dd836..4368aaa69 160000 --- a/crt/aws-lc +++ b/crt/aws-lc @@ -1 +1 @@ -Subproject commit 4e54dd8363396f257d7a2317c48101e18170e6fb +Subproject commit 4368aaa6975ba41bd76d3bb12fac54c4680247fb diff --git a/include/aws/crt/StlAllocator.h b/include/aws/crt/StlAllocator.h index 13ec6ff68..0c45d0d53 100644 --- a/include/aws/crt/StlAllocator.h +++ b/include/aws/crt/StlAllocator.h @@ -51,6 +51,10 @@ namespace Aws return static_cast(aws_mem_acquire(m_allocator, n * sizeof(T))); } +#if _LIBCPP_STD_VER > 20 + std::allocation_result allocate_at_least(size_type n) { return {allocate(n), n}; } +#endif + void deallocate(RawPointer p, size_type) { AWS_ASSERT(m_allocator); diff --git a/source/io/HostResolver.cpp b/source/io/HostResolver.cpp index 06d4d5722..b4d9ffaf3 100644 --- a/source/io/HostResolver.cpp +++ b/source/io/HostResolver.cpp @@ -79,6 +79,7 @@ namespace Aws size_t len = hostAddresses ? aws_array_list_length(hostAddresses) : 0; Vector addresses; + addresses.reserve(len); for (size_t i = 0; i < len; ++i) {