Errno fix (#463)
Correctly set errno on failure and improve the related test. Previously the malloc test would emit an error message but not abort if the errno was not as expected on failure. This was because the return in the null == true case prevented the check for failed == true at the end of check_result from being reached. To resolve this just abort immediately as in the null case. Also add tests of allocations that are expected to fail for calloc and malloc. To make the tests pass we need to set errno in several places, making sure to keep this off the fast path. We must also take care not to attempt to zero nullptr in case of calloc failure. See microsoft/snmalloc#461 and microsoft/snmalloc#463.
This commit is contained in:
@@ -151,6 +151,7 @@ namespace snmalloc
|
||||
if (align_bits == (bits::BITS - 1))
|
||||
{
|
||||
// Out of memory
|
||||
errno = ENOMEM;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user