From 8dfdad3ee84a73ec7da2312e8c8d893dd8968d17 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 12 Dec 2017 14:31:31 +1100 Subject: src/lobject.js: Have luaO_pushvfstring respect null as terminator for %s --- src/lobject.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/lobject.js b/src/lobject.js index e69a9ef..91078ed 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -526,6 +526,12 @@ const luaO_pushvfstring = function(L, fmt, argp) { case char['s']: { let s = argp[a++]; if (s === null) s = defs.to_luastring("(null)", true); + else { + /* respect null terminator */ + let i = s.indexOf(0); + if (i !== -1) + s = s.slice(0, i); + } pushstr(L, s); break; } -- cgit v1.2.3-70-g09d2