Skip to content

Fix ConvertPathToEntrynum falsely matching subpath that doesn't exist#90

Merged
Jacherr merged 1 commit into
Retro-Rewind-Team:mainfrom
y21:sd_open_error
May 1, 2026
Merged

Fix ConvertPathToEntrynum falsely matching subpath that doesn't exist#90
Jacherr merged 1 commit into
Retro-Rewind-Team:mainfrom
y21:sd_open_error

Conversation

@y21
Copy link
Copy Markdown
Collaborator

@y21 y21 commented Apr 30, 2026

Fixes a crash in FastOpen() where ConvertPathToEntrynum() would falsely allocate an entrynum for a file that doesn't actually exist. Tested on dolphin, error is gone and patches seem to work (tested with a simple la_bike-fk.szs replacement)

TL;DR: change the cached folder check from extracting just the filename (which may drop other segments that need to be compared) to comparing the full remaining path after the common prefix.

Longer explanation

Normally, when we're considering the node <folder external="/RetroRewind6/Assets" disc="/"> and we have a file in /RetroRewind6/Assets/ReplacedAssets.szs, and the game requests /patches/ReplacedAssets.szs, this should not match, because what's supposed to happen is it finds the common prefix of the disc path and requested path (just "/" here) and then append the rest onto the external path: /RetroRewind6/Assets/patches/ReplacedAssets.szs; this file doesn't exist and thus should be ignored.

The problem with the cached implementation is that it only took the filename segment (ReplacedAssets.szs) and checked if it's in the folder contents of /RetroRewind6/Assets: it is, but that ignores that the requested file was supposed to be in a patches/ subfolder.
So this changes it such that it compares the full remaining portion after the common prefix (differ_index) (usually this will just be a filename and the change won't make a difference, but in this example it would end up comparing "patches/ReplacedAssets.szs" == "ReplacedAssets.szs", which as expected no longer falsely matches)

This fixes a crash in FastOpen() where ConvertPathToEntrynum() would falsely allocate an entrynum for a file that doesn't actually exist.
@Jacherr Jacherr merged commit 9569b18 into Retro-Rewind-Team:main May 1, 2026
1 check failed
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