summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-29 20:50:40 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-29 22:07:04 +1100
commite88594ba50462b32e5857afc9c591d8185d5ba0c (patch)
tree328cea11cfd16cfbe8e1dde12d7ee8381d5f1d20 /src
parentcb38849ddfdba715b5d85f438f8479743e5d7a11 (diff)
downloadfengari-e88594ba50462b32e5857afc9c591d8185d5ba0c.tar.gz
fengari-e88594ba50462b32e5857afc9c591d8185d5ba0c.tar.bz2
fengari-e88594ba50462b32e5857afc9c591d8185d5ba0c.zip
src/lapi.js: Check upvalue index in an integer
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js4
1 files 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: {