Bug fixes (#752)

* Fix overflow by alignment

* Bug fix: Ensure bytes_free is the total

The bytes freed was not added to the total, but
overrode it.  This meant it never fired. This
commit fixes that.
This commit is contained in:
Matthew Parkinson
2025-02-27 08:52:50 +00:00
committed by GitHub
parent 5f7baef755
commit 6622dc584e
3 changed files with 44 additions and 17 deletions

View File

@@ -15,11 +15,7 @@ constexpr int SUCCESS = 0;
void check_result(size_t size, size_t align, void* p, int err, bool null)
{
bool failed = false;
EXPECT(
(errno == err) || (err == SUCCESS),
"Expected error: {} but got {}",
err,
errno);
EXPECT((errno == err), "Expected error: {} but got {}", err, errno);
if (null)
{
EXPECT(p == nullptr, "Expected null but got {}", p);
@@ -307,6 +303,9 @@ int main(int argc, char** argv)
for (size_t align = sizeof(uintptr_t); align < MAX_SMALL_SIZECLASS_SIZE * 8;
align <<= 1)
{
// Check overflow with alignment taking it round to 0.
test_memalign(1 - align, align, ENOMEM, true);
for (smallsizeclass_t sc = 0; sc < NUM_SMALL_SIZECLASSES - 6; sc++)
{
const size_t size = sizeclass_to_size(sc);