mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-03 23:47:26 +00:00
CMock_Guts_MemBytesCapacity() returned sizeof(CMock_Guts_Buffer), which is the size of the pointer variable itself (not the buffer it points to), minus CMOCK_MEM_ALIGN_SIZE. On a typical 64-bit build this is 8 - CMOCK_MEM_ALIGN_SIZE, which underflows to a huge garbage value whenever CMOCK_MEM_ALIGN_SIZE > sizeof(void*) (e.g. when it defaults to sizeof(max_align_t) on C11+ toolchains). Use CMock_Guts_BufferSize instead, which already tracks the real buffer size (including growth via realloc under CMOCK_MEM_DYNAMIC). This makes MemBytesCapacity() == MemBytesUsed() + MemBytesFree() by construction, matching the two sibling accessors.