Skip to content

fix: fail on missing Address Library ids - #15

Merged
shad0wshayd3 merged 1 commit into
libxse:mainfrom
1001Bits:fix/exact-address-library-lookup
Oct 29, 2026
Merged

shad0wshayd3 merged 1 commit into
libxse:mainfrom
1001Bits:fix/exact-address-library-lookup

Conversation

@1001Bits

Copy link
Copy Markdown
Contributor

IDDB::offset could return a wrong address instead of failing when an id is not in the loaded Address Library.

Why

  • Formats below 5: std::lower_bound lands on the next-higher id when the requested id is missing, and only end() counted as a failure, so the caller got that neighbour's offset and jumped into an unrelated function.
  • Format 5: m_v5[a_id] was read without a bounds check, so an id past the end of the table read outside the mapped data.

A plugin that uses an id its runtime does not have then crashes somewhere far from the cause instead of stopping with the usual message. CommonLibSSE-NG already does this exact-match check (it == end() || it->id != a_id).

Changes

  • Formats < 5: also fail when it->id != a_id.
  • Format 5: ids at or past m_v5.size() are treated like a zero entry.

Both cases now report the existing "Failed to find offset for Address Library ID!" message with the plugin name, id and game version.

Offset2ID::get_id (offset to id) has the same nearest-match behaviour; it is left alone here.

Testing

  • commonlib-shared builds (x64-windows-static-md)
  • Not run in game

For formats below 5, lower_bound returned the next-higher id's offset when the id was missing, so the call silently went to an unrelated address. For format 5, an id past the end of the table was read out of bounds. Both now fail with the existing 'Failed to find offset' message.
@shad0wshayd3
shad0wshayd3 merged commit be04aa9 into libxse:main Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants