From 57ce8c364cb483825e1be4e01014ceeba5e6c095 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Fri, 10 Mar 2017 10:48:46 +0100 Subject: [PATCH] LuaWrapper: Allow embedded NULs in strings received from Lua (cherry picked from commit 448990ab9bd7355f42ff8752a973aff20bdaf4e7) --- ext/luawrapper/include/LuaContext.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/luawrapper/include/LuaContext.hpp b/ext/luawrapper/include/LuaContext.hpp index e9627d689..8a0075e99 100644 --- a/ext/luawrapper/include/LuaContext.hpp +++ b/ext/luawrapper/include/LuaContext.hpp @@ -2486,10 +2486,11 @@ struct LuaContext::Reader static auto read(lua_State* state, int index) -> boost::optional { - const auto val = lua_tostring(state, index); + size_t len; + const auto val = lua_tolstring(state, index, &len); if (val == 0) return boost::none; - return std::string(val); + return std::string(val, len); } }; -- 2.49.0