Skip to content
Snippets Groups Projects
Commit 3a990b41 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

A fix and a test case for Bug#1061147 "tonumber64 is not transitive"

https://bugs.launchpad.net/tarantool/+bug/1061147

Patch contributed by Mons Anderson

When accessing Lua stack via a numeric index, first calculate
absolute value of the index.
parent 7adfce73
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,9 @@ tarantool_lua_tointeger64(struct lua_State *L, int idx)
}
case LUA_TCDATA:
{
/* Calculate absolute value in the stack. */
if (idx < 0)
idx = lua_gettop(L) + idx + 1;
GCcdata *cd = cdataV(L->base + idx - 1);
if (cd->typeid != CTID_INT64 && cd->typeid != CTID_UINT64) {
luaL_error(L,
......
No preview for this file type
......@@ -573,3 +573,7 @@ print """# A test case for bitwise operations """
exec admin "lua bit.lshift(1, 32)"
exec admin "lua bit.band(1, 3)"
exec admin "lua bit.bor(1, 2)"
print """# A test case for Bug#1061747 'tonumber64 is not transitive'"""
exec admin "lua tonumber64(tonumber64(2))"
exec admin "lua tostring(tonumber64(tonumber64(3)))"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment