Fix ConvertPathToEntrynum falsely matching subpath that doesn't exist#90
Merged
Conversation
This fixes a crash in FastOpen() where ConvertPathToEntrynum() would falsely allocate an entrynum for a file that doesn't actually exist.
Jacherr
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 apatches/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)