OoTRandomizer / OoT-Randomizer

A randomizer for Ocarina of Time.
Other
397 stars 230 forks source link

Limit CFG_SONG_NAMES to the first 47 bgm entries #2207

Closed GSKirox closed 2 months ago

GSKirox commented 2 months ago

The function patch_song_names dumped the full content of log.bgm into an area supposed to have enough room to store all music tracks shuffled. However, shuffling fanfares also add all fanfares to the same log.bgm dictionary, which make the function write a lot more than expected in the cosmetic context, and make all data stored after that completely wrong. Since the music is stored first then fanfares, we can safely limit the data written to the first 47 elements of the dictionary, which ensure we won't write past the intended allocated memory.

fenhl commented 2 months ago

As written, this seems to break seed generation with fewer than 47 bgm entries. I'm changing it to the following to fix it:

for index, song_name in enumerate(log.bgm.values()):
    if index >= 47:
        break
    ...