From d4a1e03c5fb588a8e3f41110de437b38d4e57bbf Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 11 Nov 2020 16:33:38 -0500 Subject: [PATCH] [libc++] NFC: Synchronize libc++abi and libc++ new definitions Some changes were made to the libc++abi new/delete definitions, but they were not copied back to the libc++ definition. It sucks that we have this duplication, but for now at least let's keep them in sync. --- libcxx/src/new.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 901e78565857b..ec60ca64815f5 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -130,7 +130,8 @@ _LIBCPP_WEAK void operator delete(void* ptr) _NOEXCEPT { - ::free(ptr); + if (ptr) + ::free(ptr); } _LIBCPP_WEAK @@ -251,10 +252,11 @@ _LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) _NOEXCEPT { + if (ptr) #if defined(_LIBCPP_MSVCRT_LIKE) - ::_aligned_free(ptr); + ::_aligned_free(ptr); #else - ::free(ptr); + ::free(ptr); #endif }