Skip to content

Commit

Permalink
fixes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Apr 2, 2024
1 parent 0d5f026 commit 0b45737
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extension/script/backend/worker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,11 @@ function CMD.setSearchPath(pkg)
else
value = fs.nativepath(value)
end
local visitor = rdebug.field(rdebug.field(rdebug._G, "package"), name)
if not rdebug.assign(visitor, value) then
local visitor = rdebug.field(rdebug._G, "package")
if visitor == nil then
return
end
if not rdebug.assign_field(visitor, name, value) then
return
end
end
Expand Down
18 changes: 18 additions & 0 deletions src/luadebug/rdebug_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,23 @@ namespace luadebug::visitor {
return 1;
}

static int visitor_assign_field(luadbg_State* L, lua_State* hL, protected_area& area) {
area.check_type(L, 1, LUADBG_TUSERDATA);
area.check_client_stack(3);
auto field = area.checkstring(L, 2);
if (copy_from_dbg(L, hL, area, 1) == LUADBG_TNONE) {
return 0;
}
lua_pushlstring(hL, field.data(), field.size());
if (copy_from_dbg(L, hL, area, 3) == LUADBG_TNONE) {
lua_pop(hL, 2);
return 0;
}
lua_rawset(hL, -3);
lua_pop(hL, 1);
return 0;
}

static int visitor_type(luadbg_State* L, lua_State* hL, protected_area& area) {
switch (luadbg_type(L, 1)) {
case LUADBG_TNIL:
Expand Down Expand Up @@ -915,6 +932,7 @@ namespace luadebug::visitor {
{ "udwrite", protected_call<visitor_udwrite> },
{ "value", protected_call<visitor_value> },
{ "assign", protected_call<visitor_assign> },
{ "assign_field", protected_call<visitor_assign_field> },
{ "type", protected_call<visitor_type> },
{ "getinfo", protected_call<visitor_getinfo> },
{ "load", protected_call<visitor_load> },
Expand Down

0 comments on commit 0b45737

Please sign in to comment.