From f775fe8c83364e0cc52877abf9a85bb7d88d6e46 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 8 Sep 2019 22:21:32 +0200 Subject: [PATCH] [CPU] Fix off-by-one in max ordinals check --- src/xenia/cpu/export_resolver.cc | 2 +- src/xenia/cpu/xex_module.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xenia/cpu/export_resolver.cc b/src/xenia/cpu/export_resolver.cc index 31e34feca..ecc5d8246 100644 --- a/src/xenia/cpu/export_resolver.cc +++ b/src/xenia/cpu/export_resolver.cc @@ -58,7 +58,7 @@ Export* ExportResolver::GetExportByOrdinal(const std::string_view module_name, uint16_t ordinal) { for (const auto& table : tables_) { if (xe::utf8::starts_with_case(module_name, table.module_name())) { - if (ordinal > table.exports_by_ordinal().size()) { + if (ordinal >= table.exports_by_ordinal().size()) { return nullptr; } return table.exports_by_ordinal().at(ordinal); diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 0bd727f0f..45a59847f 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -127,7 +127,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const { xex_security_info()->export_table); ordinal -= export_table->base; - if (ordinal > export_table->count) { + if (ordinal >= export_table->count) { XELOGE("GetProcAddress({:03X}): ordinal out of bounds", ordinal); return 0; }