diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-05 10:33:23 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-05 10:33:23 +1000 |
commit | b600ba0123b8af27d2d25e7655b311163afaec91 (patch) | |
tree | 082377211fe92fdd2e60c521aecaf0ad2cd64f6f /src/ltablib.js | |
parent | 84a0982085967895e9bb5e5439c09960840da2d5 (diff) | |
download | fengari-b600ba0123b8af27d2d25e7655b311163afaec91.tar.gz fengari-b600ba0123b8af27d2d25e7655b311163afaec91.tar.bz2 fengari-b600ba0123b8af27d2d25e7655b311163afaec91.zip |
Fix luaL_error callsites
- Now that luaL_error does sprintf-like formatting it shouldn't take user input
- % now needs to be escaped when passed to luaL_error
- Removes several wasteful lua->js->lua string transformations
Diffstat (limited to 'src/ltablib.js')
-rw-r--r-- | src/ltablib.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ltablib.js b/src/ltablib.js index 56ba2cd..788e236 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -47,7 +47,8 @@ const aux_getn = function(L, n, w) { const addfield = function(L, b, i) { lua.lua_geti(L, 1, i); if (!lua.lua_isstring(L, -1)) - lauxlib.luaL_error(L, lua.to_luastring(`invalid value (${lua.to_jsstring(lauxlib.luaL_typename(L, -1))}) at index ${i} in table for 'concat'`)); + lauxlib.luaL_error(L, lua.to_luastring("invalid value (%s) at index %d in table for 'concat'"), + lauxlib.luaL_typename(L, -1), i); lauxlib.luaL_addvalue(b); }; @@ -206,14 +207,14 @@ const partition = function(L, lo, up) { /* next loop: repeat ++i while a[i] < P */ while (lua.lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ - lauxlib.luaL_error(L, "invalid order function for sorting"); + lauxlib.luaL_error(L, lua.to_luastring("invalid order function for sorting")); lua.lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ while (lua.lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ - lauxlib.luaL_error(L, "invalid order function for sorting"); + lauxlib.luaL_error(L, lua.to_luastring("invalid order function for sorting")); lua.lua_pop(L, 1); /* remove a[j] */ } /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ |