Fix off-by-one error in out-of-memory check.

We should be able to allocate up to CMock_Guts_MemBytesFree() minus
CMOCK_MEM_INDEX_SIZE.  An incorrect less-than-or-equal prevented
allocating the very last byte.
This commit is contained in:
John Lindgren
2019-10-30 10:30:25 -04:00
parent ea71fb0e0e
commit c787042e6d
+1 -1
View File
@@ -45,7 +45,7 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNew(CMOCK_MEM_INDEX_TYPE size)
size = size + CMOCK_MEM_INDEX_SIZE;
if (size & CMOCK_MEM_ALIGN_MASK)
size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK;
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) <= size)
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size)
{
#ifndef CMOCK_MEM_DYNAMIC
return CMOCK_GUTS_NONE; // nothing we can do; our static buffer is out of memory