Skip to content

Commit

Permalink
Check for cancellation before accessing non-locals
Browse files Browse the repository at this point in the history
in order to avoid #11460
  • Loading branch information
mstv committed Dec 20, 2023
1 parent ee337ca commit 2cb7fff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ public void PerformRefreshRevisions(Func<RefsFilter, IReadOnlyList<IGitRef>> get
? getUnfilteredRefs.Value.Where(r => r.CompleteName != GitRefName.RefsStashPrefix)
: getUnfilteredRefs.Value)
.ToLookup(gitRef => gitRef.ObjectId);
cancellationToken.ThrowIfCancellationRequested();
ResetNavigationHistory();
UpdateSelectedRef(capturedModule, getUnfilteredRefs.Value, headRef.Value);
_gridView.ToBeSelectedObjectIds = GetToBeSelectedRevisions(CurrentCheckout, currentlySelectedObjectIds);
Expand Down Expand Up @@ -1077,6 +1078,7 @@ public void PerformRefreshRevisions(Func<RefsFilter, IReadOnlyList<IGitRef>> get
{
RevisionReader reader = new(capturedModule);
string pathFilter = BuildPathFilter(_filterInfo.PathFilter);
cancellationToken.ThrowIfCancellationRequested();
ParentsAreRewritten = _filterInfo.HasRevisionFilter;
cancellationToken.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -1126,6 +1128,7 @@ static void UpdateSelectedRef(IGitModule module, IReadOnlyList<IGitRef> gitRefs,

string BuildPathFilter(string? path)
{
cancellationToken.ThrowIfCancellationRequested();
FilePathByObjectId?.Clear();

if (string.IsNullOrWhiteSpace(path))
Expand Down Expand Up @@ -1219,6 +1222,7 @@ string BuildPathFilter(string? path)
}

// Add only the first file to the dictionary
cancellationToken.ThrowIfCancellationRequested();
FilePathByObjectId?.TryAdd(currentObjectId, line);
setOfFileNames.Add(line);
}
Expand Down

0 comments on commit 2cb7fff

Please sign in to comment.