[PATCH] D28512: [libc++] Pair _aligned_malloc with _aligned_free
Shoaib Meenai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 10 01:22:38 PST 2017
smeenai created this revision.
smeenai added reviewers: compnerd, EricWF, mclow.lists.
smeenai added a subscriber: cfe-commits.
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
https://reviews.llvm.org/D28512
Files:
src/new.cpp
Index: src/new.cpp
===================================================================
--- src/new.cpp
+++ src/new.cpp
@@ -198,7 +198,11 @@
operator delete(void* ptr, std::align_val_t) _NOEXCEPT
{
if (ptr)
+#if defined(_LIBCPP_MSVCRT)
+ ::_aligned_free(ptr);
+#else
::free(ptr);
+#endif
}
_LIBCPP_WEAK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28512.83783.patch
Type: text/x-patch
Size: 329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170110/448e433a/attachment.bin>
More information about the cfe-commits
mailing list