diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-04 11:54:16 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-04 11:55:49 +1000 |
commit | 24e4656be7105e090e2f1a76a294daf2d9c293af (patch) | |
tree | 92d92591e70766bfd962e5e8f95300fad59a024c /src/lapi.js | |
parent | adb15f3073139981fa38ed61587513a92065cf03 (diff) | |
download | fengari-24e4656be7105e090e2f1a76a294daf2d9c293af.tar.gz fengari-24e4656be7105e090e2f1a76a294daf2d9c293af.tar.bz2 fengari-24e4656be7105e090e2f1a76a294daf2d9c293af.zip |
Add more/correct validation around integers
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js index 6ef5a9e..909822f 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -205,9 +205,9 @@ const lua_pushnumber = function(L, n) { }; const lua_pushinteger = function(L, n) { - assert(typeof n === "number"); + assert(typeof n === "number" && (n|0) === n); - L.stack[L.top++] = new TValue(CT.LUA_TNUMINT, n|0); + L.stack[L.top++] = new TValue(CT.LUA_TNUMINT, n); assert(L.top <= L.ci.top, "stack overflow"); }; @@ -374,7 +374,7 @@ const lua_setfield = function(L, idx, k) { }; const lua_seti = function(L, idx, n) { - assert(typeof n === "number"); + assert(typeof n === "number" && (n|0) === n); assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack"); let t = index2addr(L, idx); L.stack[L.top++] = new TValue(CT.LUA_TNUMINT, n); @@ -587,6 +587,7 @@ const lua_getfield = function(L, idx, k) { }; const lua_geti = function(L, idx, n) { + assert(typeof n === "number" && (n|0) === n); let t = index2addr(L, idx); L.stack[L.top++] = new TValue(CT.LUA_TNUMINT, n); assert(L.top <= L.ci.top, "stack overflow"); |