Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 12495: Infinite loop in ToolStripItemCollection.AddRange #12513

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Olina-Zhang
Copy link
Member

@Olina-Zhang Olina-Zhang commented Nov 20, 2024

Fixes #12495 and #4454

Proposed changes

  • Early return for empty collection
  • Converts the ToolStripItemCollection into a temporary array (using ToArray()) to avoid modifying the original collection during iteration. This ensures that items can be safely added to the new collection without causing exceptions or unintended behavior, especially when items are removed from the original collection if they have a different owner control.
  • Add unit test for issue Infinite loop in ToolStripItemCollection.AddRange #12495 case

Regression?

  • Yes

Test methodology

  • Test fixing for GH issues: 12495 and 4454 manually
  • Unit test
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.73237%. Comparing base (af49f16) to head (2f4c086).
Report is 23 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12513         +/-   ##
===================================================
- Coverage   75.73242%   75.73237%   -0.00006%     
===================================================
  Files           3153        3157          +4     
  Lines         635807      636123        +316     
  Branches       46975       47004         +29     
===================================================
+ Hits          481512      481751        +239     
- Misses        150870      150900         +30     
- Partials        3425        3472         +47     
Flag Coverage Δ
Debug 75.73237% <100.00000%> (-0.00006%) ⬇️
integration 18.16407% <0.00000%> (-0.09047%) ⬇️
production 49.28844% <100.00000%> (-0.01708%) ⬇️
test 97.04462% <100.00000%> (-0.00532%) ⬇️
unit 46.52041% <100.00000%> (+0.25733%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

---- 🚨 Try these New Features:

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Nov 20, 2024
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Nov 21, 2024
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added minor comments in additions to Leaf's one

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Nov 22, 2024
Copy link
Member

@LeafShi1 LeafShi1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

Infinite loop in ToolStripItemCollection.AddRange
4 participants