forked from OSchip/llvm-project
[libc++] Pair _aligned_malloc with _aligned_free
Attempting to pair an `_aligned_malloc` with a regular free causes heap corruption. Pairing with `_aligned_free` is required instead. Makes the following libc++ tests pass on Windows: ``` std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp ``` Differential Revision: https://reviews.llvm.org/D28512 llvm-svn: 291743
This commit is contained in:
parent
9087bbee85
commit
7ce92f73f2
|
@ -198,7 +198,11 @@ void
|
|||
operator delete(void* ptr, std::align_val_t) _NOEXCEPT
|
||||
{
|
||||
if (ptr)
|
||||
#if defined(_LIBCPP_MSVCRT)
|
||||
::_aligned_free(ptr);
|
||||
#else
|
||||
::free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK
|
||||
|
|
Loading…
Reference in New Issue