From: Wolfgang Bangerth Date: Tue, 29 Oct 2024 02:17:22 +0000 (-0600) Subject: Skip an assert for posix_memalign if size==0. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5853c7b59bcb2992d6b513b5c14e3a4f9bb63ed2;p=dealii.git Skip an assert for posix_memalign if size==0. POSIX says that the returned pointer can be a nullptr if the size requested is zero. So skip the assertion if size==0. --- diff --git a/source/base/utilities.cc b/source/base/utilities.cc index 4485574b33..c193f201f7 100644 --- a/source/base/utilities.cc +++ b/source/base/utilities.cc @@ -1047,7 +1047,8 @@ namespace Utilities const int ierr = ::posix_memalign(memptr, alignment, size); AssertThrow(ierr == 0, ExcOutOfMemory(size)); - AssertThrow(*memptr != nullptr, ExcOutOfMemory(size)); + if (size > 0) + AssertThrow(*memptr != nullptr, ExcOutOfMemory(size)); #else // Windows does not appear to have posix_memalign. just use the // regular malloc in that case