1

Closed

Crash on negative table index access

description

NeoLua crashes when trying to access negative indices in a table. For example, when calling the test function in the following lua code:
local tbl = {}

function test()
    tbl[0] = 57
    print(tbl[0])

    tbl[-1] = 42
    print(tbl[-1])
end
NeoLua crashes after printing "57", with the following exception:

A first chance exception of type 'System.IndexOutOfRangeException' occurred in Neo.Lua.dll
An exception of type 'System.IndexOutOfRangeException' occurred in Neo.Lua.dll but was not handled in user code
Additional information: Index was outside the bounds of the array.


Since lua tables are associative arrays, one would expect negative indices to be allowed, and the aforementioned test code runs correctly in standard Lua.
Closed Mar 27, 2015 at 9:41 AM by NeoLithos

comments

NeoLithos wrote Mar 14, 2015 at 6:15 PM

Thanks.

There was a error in the hash calculation of the index values.
I fixed it (Commit).


Do you need a release version?

wrote Mar 14, 2015 at 6:18 PM

wrote Mar 27, 2015 at 9:41 AM