From e88594ba50462b32e5857afc9c591d8185d5ba0c Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 29 Jan 2018 20:50:40 +1100 Subject: src/lapi.js: Check upvalue index in an integer --- src/lapi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lapi.js b/src/lapi.js index 0ea700c..2d0e7c2 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1079,7 +1079,7 @@ const getupvalref = function(L, fidx, n) { let fi = index2addr(L, fidx); api_check(L, fi.ttisLclosure(), "Lua function expected"); let f = fi.value; - api_check(L, 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index"); + api_check(L, n|0 === n && 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index"); return { f: f, i: n - 1 @@ -1095,7 +1095,7 @@ const lua_upvalueid = function(L, fidx, n) { } case LUA_TCCL: { /* C closure */ let f = fi.value; - api_check(L, 1 <= n && n <= f.nupvalues, "invalid upvalue index"); + api_check(L, n|0 === n && 1 <= n && n <= f.nupvalues, "invalid upvalue index"); return f.upvalue[n - 1]; } default: { -- cgit v1.2.3-70-g09d2