amx_Allot() returns success when it shouldn't
#1

There's a bug in amx_Allot() where it checks whether there's enough space on the heap:

Код:
if (amx->stk - amx->hea - cells*sizeof(cell) < STKMARGIN)
  return AMX_ERR_MEMORY;
The expression on the left is always positive because of the convertion to size_t (which is unsigned). It can be fixed by replacing the first line with:

Код:
if ((size_t)amx->stk < (size_t)(amx->hea + cells*sizeof(cell) + STKMARGIN))
This also affects amx_PushString() and amx_PushArray() as they use this function internally.
Reply


Messages In This Thread
amx_Allot() returns success when it shouldn't - by xeeZ - 20.01.2014, 19:00
Re: amx_Allot() returns success when it shouldn't - by ][Noname][ - 20.01.2014, 20:30
Re: amx_Allot() returns success when it shouldn't - by xeeZ - 21.01.2014, 05:01
Re: amx_Allot() returns success when it shouldn't - by xeeZ - 13.02.2014, 12:57
Re: amx_Allot() returns success when it shouldn't - by Reboma - 13.02.2014, 21:38
Re: amx_Allot() returns success when it shouldn't - by xeeZ - 14.02.2014, 15:34
Re: amx_Allot() returns success when it shouldn't - by Jachu - 14.02.2014, 18:25
Re: amx_Allot() returns success when it shouldn't - by Kar - 09.03.2015, 16:53

Forum Jump:


Users browsing this thread: 1 Guest(s)