Skip to content

Commit

Permalink
Fix potential exception in PathEntryCollection path resolving
Browse files Browse the repository at this point in the history
see also #4077 for where this initially came up
  • Loading branch information
Morilli committed Oct 5, 2024
1 parent 7b2de12 commit 97785b2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,25 @@ private static string AbsolutePathForInner(this PathEntryCollection collection,
return path;
}

if (path.IsAbsolute())
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER
bool isAbsolute = path.IsAbsolute();
#else
bool isAbsolute;
try
{
return path;
isAbsolute = path.IsAbsolute();
}
catch
{
isAbsolute = false;
}
#endif

//handling of initial .. was removed (Path.GetFullPath can handle it)
//handling of file:// or file:\\ was removed (can Path.GetFullPath handle it? not sure)

// all bad paths default to EXE
return PathUtils.ExeDirectoryPath;
return isAbsolute ? path : PathUtils.ExeDirectoryPath;
}

public static string MovieAbsolutePath(this PathEntryCollection collection)
Expand Down

0 comments on commit 97785b2

Please sign in to comment.