diff --git a/common/luajit.cc b/common/luajit.cc index 1e7b25a..72856c6 100644 --- a/common/luajit.cc +++ b/common/luajit.cc @@ -188,7 +188,7 @@ void PushVector(lua_State* L, const nf7::Value::ConstVector& v) noexcept { if (lua_istable(L, -1)) { // array lua_rawgeti(L, -1, 1); const std::string_view type = luaL_checkstring(L, -1); - lua_rawgeti(L, -1, 2); + lua_rawgeti(L, -2, 2); const size_t n = static_cast(luaL_checkinteger(L, -1)); lua_pop(L, 2); @@ -553,6 +553,7 @@ static size_t PushArrayFromBytes(lua_State* L, size_t n, const uint8_t* ptr, con [] () { static_assert(F, "T is invalid"); }(); } lua_rawseti(L, -2, static_cast(i + 1)); + ptr += sizeof(T); } return size; } diff --git a/common/luajit_thread.cc b/common/luajit_thread.cc index db8bc80..51a321b 100644 --- a/common/luajit_thread.cc +++ b/common/luajit_thread.cc @@ -204,7 +204,11 @@ static void PushMeta(lua_State* L) noexcept { const int n = lua_gettop(L); std::stringstream st; for (int i = 2; i <= n; ++i) { - st << lua_tostring(L, i); + if (auto msg = lua_tostring(L, i)) { + st << msg; + } else { + return luaL_error(L, "cannot stringify %s", luaL_typename(L, i)); + } } logger->Write({lv, st.str()}); return 0;