From e96864a79c3bf708aa4e0fc7e26930324a35f0b5 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Mon, 3 Jul 2023 02:43:52 +0200 Subject: [PATCH] Fix argument validation in Lua command `cell:getAll` --- apps/openmw/mwlua/cellbindings.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwlua/cellbindings.cpp b/apps/openmw/mwlua/cellbindings.cpp index ade50cf289..914f3f5fcc 100644 --- a/apps/openmw/mwlua/cellbindings.cpp +++ b/apps/openmw/mwlua/cellbindings.cpp @@ -88,19 +88,15 @@ namespace MWLua return true; }; - bool ok = false; - sol::optional typeId = sol::nullopt; - if (type.has_value()) - typeId = ids[*type]; + bool ok = true; + if (!type.has_value()) + cell.mStore->forEach(std::move(visitor)); + else if (ids[*type] == sol::nil) + ok = false; else { - ok = true; - cell.mStore->forEach(std::move(visitor)); - } - if (typeId.has_value()) - { - ok = true; - switch (*typeId) + uint32_t typeId = ids[*type]; + switch (typeId) { case ESM::REC_INTERNAL_PLAYER: {