From a9ab7635a0c31f1091e3f3caff089e5b8fc1190e Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Tue, 18 Feb 2020 17:15:30 +0300 Subject: [PATCH] fix problem with sharing string: now it is passible to share non-null-terminated string --- src/script.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/script.c b/src/script.c index 68a5d081..e17f36dc 100644 --- a/src/script.c +++ b/src/script.c @@ -485,8 +485,11 @@ void script_copy_value(lua_State *src, lua_State *dst, int index) { case LUA_TNUMBER: lua_pushnumber(dst, lua_tonumber(src, index)); break; - case LUA_TSTRING: - lua_pushstring(dst, lua_tostring(src, index)); + case LUA_TSTRING: { + size_t len = 0; + const char *str = lua_tolstring(src, index, &len); + lua_pushlstring(dst, str, len); + } break; case LUA_TTABLE: lua_newtable(dst);