Skip to content

Load the game from its path when the frontend gives no data - #219

Open
sunlollyking wants to merge 1 commit into
libretro:masterfrom
sunlollyking:load-from-path
Open

sunlollyking wants to merge 1 commit into
libretro:masterfrom
sunlollyking:load-from-path

Conversation

@sunlollyking

Copy link
Copy Markdown

melonDS asks for the game in memory, but a frontend that can't load it there gives only the path. Kodi does this when a game won't fit in the memory it has. NDS::LoadROM() then copied from a null pointer and melonDS ran an empty cart, which crashes on some games.

With no data, the ROM is now read from info->path with the existing NDS::LoadROM(path), which reads straight into the cart, so there's no second copy. A path that can't be opened fails the load. The GBA slot does the same.

retro_reset() loads the game again the same way. It used to go through the frontend's retro_game_info pointer, but persistent_data only keeps the data, not the struct, so a frontend that builds it on the stack left it dangling.

Tested in Kodi on Linux with a DS game padded past Kodi's in-memory limit, so Kodi passed only the path. Before: an empty cart ("Game code:" blank, "ROM entry not found"). After: the game loads (YK6E), and loads again on reset. Loading from memory, and resetting, work as before.

melonDS asks for the game in memory, but a frontend that can't load it
there, such as Kodi when a game is too big for the memory it has, gives
only the path. LoadROM() then copied from a null pointer and melonDS ran
an empty cart, which crashes on some games.

Without data the ROM is now read from the path, straight into the cart
with no second copy, and a path that can't be opened fails the load.
retro_reset() loads the game again the same way: it kept the frontend's
retro_game_info pointer, which isn't guaranteed to outlive
retro_load_game().
sunlollyking added a commit to sunlollyking/game.libretro.melonds that referenced this pull request Oct 29, 2026
Carries libretro/melonDS#219 until it is merged. When game.libretro
can't give melonDS the game in memory it passes only the path, and
melonDS ran an empty cart, which crashes on some games. It now reads the
game from the path, and loads it again the same way on reset.
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.

1 participant