diff --git a/src/logic/scripting/lua/libs/libgui.cpp b/src/logic/scripting/lua/libs/libgui.cpp index af317f94..68327c8e 100644 --- a/src/logic/scripting/lua/libs/libgui.cpp +++ b/src/logic/scripting/lua/libs/libgui.cpp @@ -490,6 +490,12 @@ static int p_get_scroll(UINode* node, lua::State* L) { } static int l_gui_getattr(lua::State* L) { + if (!lua::isstring(L, 1)) { + throw std::runtime_error("document name is not a string"); + } + if (!lua::isstring(L, 2)) { + throw std::runtime_error("element id is not a string"); + } auto docname = lua::require_string(L, 1); auto element = lua::require_string(L, 2); if (lua::isnumber(L, 3)) { @@ -507,6 +513,9 @@ static int l_gui_getattr(lua::State* L) { const auto& id = request_node_id(DocumentNode {docnode.document, node}); return push_document_node(L, id); } + if (!lua::isstring(L, 3)) { + throw std::runtime_error("attribute name is not a string"); + } auto attr = lua::require_string(L, 3); static const std::unordered_map< @@ -755,6 +764,15 @@ static int p_set_scroll(UINode* node, lua::State* L, int idx) { } static int l_gui_setattr(lua::State* L) { + if (!lua::isstring(L, 1)) { + throw std::runtime_error("document name is not a string"); + } + if (!lua::isstring(L, 2)) { + throw std::runtime_error("element id is not a string"); + } + if (!lua::isstring(L, 3)) { + throw std::runtime_error("attribute name is not a string"); + } auto docname = lua::require_string(L, 1); auto element = lua::require_string(L, 2); auto attr = lua::require_string(L, 3);