Skip to content

Commit 7d45104

Browse files
committed
Fixed invalid construction of string from string_view
1 parent d947087 commit 7d45104

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/lua_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ namespace AsyncIO::LuaUtils {
77
do {
88
firstPos = endPos;
99
endPos = path.find(".", endPos) + 1;
10-
std::string name{ path.substr(firstPos, endPos != 0 ? endPos - firstPos - 1 : path.size()) };
10+
std::string_view name = path.substr(firstPos, endPos != 0 ? endPos - firstPos - 1 : path.size());
11+
std::string name_copy {name.data(), name.size()};
1112

12-
LUA->GetField(firstPos == 0 ? GarrysMod::Lua::INDEX_GLOBAL : -1, name.c_str());
13+
LUA->GetField(firstPos == 0 ? GarrysMod::Lua::INDEX_GLOBAL : -1, name_copy.c_str());
1314
if (firstPos != 0) LUA->Remove(-2);
1415
if (!LUA->IsType(-1, GarrysMod::Lua::Type::Table)) break;
1516
} while (endPos != 0);

0 commit comments

Comments
 (0)