Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add missing lock around files variable
The files dictionary could be modified and resized by another thread. Without the lock, the read is not synchronized and can cause a KeyNotFoundException.
  • Loading branch information
wimoy committed Apr 7, 2025
commit eb91e30da04a5448d43542d9b135727086f4317f
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ private string GetPathWithCorrectDirectoryCapitalization(string fullPath)

if (DirectoryExistsWithoutFixingPath(leftHalf))
{
string baseDirectory = files[leftHalf].Path;
string baseDirectory;
lock (files)
{
baseDirectory = files[leftHalf].Path;
}

return baseDirectory + Path.DirectorySeparatorChar + rightHalf;
}
}
Expand Down Expand Up @@ -581,4 +586,4 @@ private class FileSystemEntry
public string Path { get; set; }
public MockFileData Data { get; set; }
}
}
}