lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mar 31, 2014, at 6:03 PM, Doug Currie <> wrote:

> On Mon, Mar 31, 2014 at 6:33 PM, Paige DePol <> wrote:
> ... I favour adding the sanity check to lua_checkstack() as it potentially helps prevent future issues should a negative value be passed for 'size'. My fix simply adds one line to lua_checkstack() and changes one comparison in unpack() to fix the issue as well.
> The only argument I have against the change in lua_checkstack() is that it is not necessary, and may affect things I don't understand. [It also uses new C99 features, which is easily fixed.]
> The unpack solution happens to work for this compiler, but uses unspecified compiler behavior since the subtraction still overflows. So, it is not portable.
> e

Upon further reading I think I have a better understanding of the arithmetic overflow issues with respect to signed vs unsigned numbers. Your solution should be the most portable and I will update my patch to use it, thank you!

However, I also think that lua_checkstack() should have some sort of sanity check for negative values as the function does seem to assume that 'size' will always be zero or greater. Which new C99 features does it use, btw?