8000 Fixing Coverity Defects Part Deux by whoisj · Pull Request #1130 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Fixing Coverity Defects Part Deux #1130

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes race condition defect found by Coverity
  • Loading branch information
J Wyman committed Jul 8, 2015
commit e5e169d4d3353aaf640482e36acea7a2777b09e6
15 changes: 9 additions & 6 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static void DeregisterFilter(FilterRegistration registration)

// do nothing if the filter isn't registered
if (registeredFilters.ContainsKey(filter))
{
{
// remove the register from the global tracking list
registeredFilters.Remove(filter);
// clean up native allocations
Expand All @@ -264,12 +264,15 @@ internal static void DeregisterFilter(Filter filter)
{
System.Diagnostics.Debug.Assert(filter != null);

// do nothing if the filter isn't registered
if (registeredFilters.ContainsKey(filter))
lock (registeredFilters)
{
var registration = registeredFilters[filter];
// unregister the filter
DeregisterFilter(registration);
// do nothing if the filter isn't registered
if (registeredFilters.ContainsKey(filter))
{
var registration = registeredFilters[filter];
// unregister the filter
DeregisterFilter(registration);
}
}
}
}
Expand Down
0