[CPU] Fix off-by-one in max ordinals check
This commit is contained in:
parent
9205a6b062
commit
f775fe8c83
|
@ -58,7 +58,7 @@ Export* ExportResolver::GetExportByOrdinal(const std::string_view module_name,
|
||||||
uint16_t ordinal) {
|
uint16_t ordinal) {
|
||||||
for (const auto& table : tables_) {
|
for (const auto& table : tables_) {
|
||||||
if (xe::utf8::starts_with_case(module_name, table.module_name())) {
|
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 nullptr;
|
||||||
}
|
}
|
||||||
return table.exports_by_ordinal().at(ordinal);
|
return table.exports_by_ordinal().at(ordinal);
|
||||||
|
|
|
@ -127,7 +127,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const {
|
||||||
xex_security_info()->export_table);
|
xex_security_info()->export_table);
|
||||||
|
|
||||||
ordinal -= export_table->base;
|
ordinal -= export_table->base;
|
||||||
if (ordinal > export_table->count) {
|
if (ordinal >= export_table->count) {
|
||||||
XELOGE("GetProcAddress({:03X}): ordinal out of bounds", ordinal);
|
XELOGE("GetProcAddress({:03X}): ordinal out of bounds", ordinal);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue