From 58917b03d167ba96afd5e5d66e7ee6ab7a4b0a20 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 24 Oct 2020 14:27:33 -0400 Subject: [PATCH] Switch away from CheckDFObject in unprotected calls See https://github.com/DFHack/dfhack/pull/1674#issuecomment-716028460 --- plugins/buildingplan.cpp | 5 ++++- plugins/fortplan.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index 82551be23..3390b04b0 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -303,11 +303,14 @@ static bool construct_planned_building() return false; } - auto bld = Lua::CheckDFObject(L, -1); + auto bld = Lua::GetDFObject(L, -1); lua_pop(L, 1); if (!bld) + { + out.printerr("buildingplan: construct_building_from_ui_state() failed\n"); return false; + } planner.addPlannedBuilding(bld); diff --git a/plugins/fortplan.cpp b/plugins/fortplan.cpp index 07685ca2b..8b8dc5584 100644 --- a/plugins/fortplan.cpp +++ b/plugins/fortplan.cpp @@ -72,11 +72,14 @@ struct BuildingInfo { if (!Lua::SafeCall(out, L, 4, 1)) return false; - auto bld = Lua::CheckDFObject(L, -1); + auto bld = Lua::GetDFObject(L, -1); lua_pop(L, 1); if (!bld) + { + out.printerr("fortplan: construct_building_from_params() failed\n"); return false; + } planner.addPlannedBuilding(bld);