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

Add lock in ValidateName #110780

Merged

Conversation

MaxPatri
Copy link
Contributor

Added lock in ValidateName function.
Lock is required because after calculating Math.Min(_siteCount, _sites!.Length) we can meet situation when _sites length might be less than calculated value and we get out of bounds exception.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

@@ -221,18 +221,21 @@ protected virtual void ValidateName(IComponent component, string? name)
{
ArgumentNullException.ThrowIfNull(component);

if (name != null)
lock (_syncObj)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to add the lock when name is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason, fixed

@steveharter steveharter added the needs-author-action An issue or pull request that requires more info or actions from the author. label Dec 30, 2024
@steveharter steveharter merged commit 9e6b45c into dotnet:main Jan 14, 2025
80 of 82 checks passed
steveharter pushed a commit to steveharter/runtime that referenced this pull request Jan 24, 2025
steveharter pushed a commit to steveharter/runtime that referenced this pull request Jan 24, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.ComponentModel community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants