[libc++] Use correct size for deallocation of arrays in shared_ptr (#68233)
authorIlya Biryukov <ibiryukov@google.com>
Thu, 5 Oct 2023 13:27:58 +0000 (15:27 +0200)
committerTobias Hieta <tobias@hieta.se>
Mon, 20 Nov 2023 08:50:27 +0000 (09:50 +0100)
commitb5cbb35408a3901900dc2b2ca6adda80a77ea093
treeef8bcc9200cb983f96b5da2be987699711200028
parente6de86cb9ef868c652d8932db2c08f953f47a1e2
[libc++] Use correct size for deallocation of arrays in shared_ptr (#68233)

Fixes #68051.

Current implementation passes the number of `_AlignedStorage` objects
when it calls to `allocate` and the number of **bytes** on `deallocate`.
This only applies to allocations that allocate control block and the
storage together, i.e. `make_shared` and `allocate_shared`.

Found by ASan under Clang combined with `-fsized-deallocation`.

(cherry picked from commit f722db02d359e29ca001b78197ee1a275f8c3d7c)
libcxx/include/__memory/shared_ptr.h
libcxx/test/libcxx/memory/shared_ptr_array.pass.cpp [new file with mode: 0644]