diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-23 18:02:56 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-27 22:14:40 +1000 |
commit | cc371ddf515fc40d7fbbb8a4e4040673de127c50 (patch) | |
tree | 538e8f171b0be55f6195f0acd7700fa786eb9dce /src | |
parent | 78f764030414e5c45ea059a5f582885da0282e39 (diff) | |
download | fengari-cc371ddf515fc40d7fbbb8a4e4040673de127c50.tar.gz fengari-cc371ddf515fc40d7fbbb8a4e4040673de127c50.tar.bz2 fengari-cc371ddf515fc40d7fbbb8a4e4040673de127c50.zip |
src/lapi.js: Ignore 's' when lua_pushlstring is passed 0
Diffstat (limited to 'src')
-rw-r--r-- | src/lapi.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js index 8b2e164..2341722 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -232,10 +232,14 @@ const lua_pushinteger = function(L, n) { }; const lua_pushlstring = function(L, s, len) { - assert(Array.isArray(s), "lua_pushlstring expects array of byte"); assert(typeof len === "number"); - - let ts = lstring.luaS_bless(L, s.slice(0, len)); + let ts; + if (len === 0) { + ts = lstring.luaS_bless(L, []); + } else { + assert(Array.isArray(s), "lua_pushlstring expects array of byte"); + ts = lstring.luaS_bless(L, s.slice(0, len)); + } lobject.setsvalue2s(L, L.top, ts); L.top++; assert(L.top <= L.ci.top, "stack overflow"); |