
There seems to be a bug in this line.
headerPtr = &allocationHeader;
Should be changed to *headerPtr = allocationHeader; otherwise the padding value is not recorded in the header memory.
I tested the original code, and the stack head address mismatches after one allocation and one free.

There seems to be a bug in this line.
headerPtr = &allocationHeader;Should be changed to
*headerPtr = allocationHeader;otherwise the padding value is not recorded in the header memory.I tested the original code, and the stack head address mismatches after one allocation and one free.