summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js
index b42ad92..4836e12 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -235,12 +235,12 @@ const lua_pushlstring = function(L, s, len) {
let ts;
if (len === 0) {
s = defs.to_luastring("", true);
+ ts = lstring.luaS_bless(L, s);
} else {
s = defs.from_userstring(s);
assert(s.length >= len, "invalid length to lua_pushlstring");
- s = s.slice(0, len);
+ ts = lstring.luaS_new(L, s.subarray(0, len));
}
- ts = lstring.luaS_bless(L, s);
lobject.pushsvalue2s(L, ts);
assert(L.top <= L.ci.top, "stack overflow");