From 0ad47e19d91dbfc04f890cdbbd09f7cf9f3e9d5f Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 27 Apr 2017 01:56:56 +1000 Subject: Add a couple of asserts to catch common errors --- src/ldo.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ldo.js') diff --git a/src/ldo.js b/src/ldo.js index 9b845e7..fa59e0b 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -77,6 +77,7 @@ const luaD_precall = function(L, off, nresults) { luaD_hook(L, defs.LUA_HOOKCALL, -1); let n = f(L); /* do the actual call */ + assert(typeof n == "number" && n >= 0 && n==n|0, "invalid return value from JS function (expected integer)"); assert(n < L.top - L.ci.funcOff, "not enough elements in the stack"); luaD_poscall(L, ci, L.top - n, n); -- cgit v1.2.3-54-g00ecf