From cc371ddf515fc40d7fbbb8a4e4040673de127c50 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 23 May 2017 18:02:56 +1000 Subject: src/lapi.js: Ignore 's' when lua_pushlstring is passed 0 --- src/lapi.js | 10 +++++++--- 1 file 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"); -- cgit v1.2.3-70-g09d2