pret / pokeemerald

Decompilation of Pokémon Emerald
2.2k stars 2.36k forks source link

Fix HideMapNamePopUpWindow possible overflow #1978

Closed DizzyEggg closed 7 months ago

DizzyEggg commented 7 months ago

Followup to #1976

We found the cause of the glitching map graphics. It was GetMapNamePopUpWindowId passing 0xFF as valid windowId, which in turn modifies the data directly below gWindows, which happened to be gHeap on some compiler/linker versions. In vanilla this goes unnoticed.

GriffinRichards commented 7 months ago

It's too bad they didn't have a single point of reference for gWindows, it'd be nice to do this kind of check there (because I wouldn't be surprised if there are some other places this is happening quietly). But by my count there's 23 functions that access gWindows with an arbitrary window id, so this is definitely the less intrusive fix.