diff --git a/apps/openmw/mwlua/dialoguebindings.cpp b/apps/openmw/mwlua/dialoguebindings.cpp index 22681908f0..8a24e999b0 100644 --- a/apps/openmw/mwlua/dialoguebindings.cpp +++ b/apps/openmw/mwlua/dialoguebindings.cpp @@ -101,14 +101,14 @@ namespace const ESM::Dialogue* at(size_t index) const { - if (index >= getSize()) + auto result = begin(); + result += index; + + if (result == end()) { return nullptr; } - auto result = begin(); - result += index; - return &(*result); }