alandtse / CommonLibVR

This is an experimental reverse engineered library for Skyrim VR (ported from CommonLibSSE). There are two main branches (VR) which is based on po3's using ifdefs, and NG which is an updated NG build.
MIT License
21 stars 18 forks source link

CTD with TESDataHandler::LookupLoadedModByIndex #9

Closed muenchk closed 1 year ago

muenchk commented 1 year ago

When using TESDataHandler::LookupLoadedModByIndex, a CTD occurs if the plugin is not found.

Example: RE::TESDataHandler* datahandler = RE::TESDataHandler::GetSingleton(); RE::TESFile* file = datahandler->GetLoadedModByIndex(0xF3);

crashes when there is no mod with index 0xF3. The crash occurs in line 95: if (file->compileIndex == a_index) { due to a null dereference on file, which occurs due to the usage of a static array in VR.

Changing the line to if (file && file->compileIndex == a_index) { fixes the issue.

The same issue should also occur in line 78, when trying to find a plugin that is not present.

alandtse commented 1 year ago

Thanks. Feel free to submit a PR or I'll get to it next time I do a revision.