Permalink
Browse files

LuaWrapper: Allow embedded NULs in strings received from Lua

(cherry picked from commit 448990a)
  • Loading branch information...
Habbie authored and pieterlexis committed Mar 10, 2017
1 parent 18ae741 commit ffdd813a64e642f9407e379baa498ec13a683a8e
Showing with 3 additions and 2 deletions.
  1. +3 −2 ext/luawrapper/include/LuaContext.hpp
@@ -2486,10 +2486,11 @@ struct LuaContext::Reader<std::string>
static auto read(lua_State* state, int index)
-> boost::optional<std::string>
{
- 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);
}
};

0 comments on commit ffdd813

Please sign in to comment.