Merge pull request #2397 from NahuelGenchi/fix/libc-posix-memalign-huge
fix(libc): return ENOMEM from posix_memalign for sizes the default heap rejects
This commit is contained in:
commit
11cb1b75ab
|
|
@ -47,6 +47,7 @@ int APS5_VABI defaultPosixAlign(void** pointer, std::size_t alignment, std::size
|
|||
if (pointer == nullptr || alignment < sizeof(void*) || (alignment & (alignment - 1)) != 0) return 22;
|
||||
try { *pointer = defaultAlign(alignment, bytes); return 0; }
|
||||
catch (const std::bad_alloc&) { return 12; }
|
||||
catch (const std::length_error&) { return 12; }
|
||||
}
|
||||
|
||||
std::array<void*, 10> defaultApi() {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,9 @@ int main(int argc, char** argv) {
|
|||
require(ApplicationHeapPosixAlign_nid_no_patch(&aligned, 256, 99) == 0);
|
||||
require(reinterpret_cast<std::uintptr_t>(aligned) % 256 == 0);
|
||||
ApplicationHeapFree_nid_no_patch(aligned);
|
||||
void* refused = nullptr;
|
||||
require(ApplicationHeapPosixAlign_nid_no_patch(&refused, 256, SIZE_MAX) == 12 && refused == nullptr);
|
||||
require(posix_memalign_nid_postfix(&refused, 4096, SIZE_MAX - 4096) == 12 && refused == nullptr);
|
||||
ApplicationHeapFree_nid_no_patch(nullptr);
|
||||
reject([] { ApplicationHeapCalloc_nid_no_patch(SIZE_MAX, 2); });
|
||||
reject([] { ApplicationHeapAlign_nid_no_patch(3, 16); });
|
||||
|
|
|
|||
Loading…
Reference in New Issue