Skip to content

Conversation

@brianrob
Copy link
Member

If an ETL file is malformed, it's possible to end up with a null handle in ETWTraceEventSource.handles. Ensure that we only dispose of non-null handles.

foreach (TraceEventNativeMethods.SafeTraceHandle handle in handles)
{
handle.Dispose();
handle?.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

Should you also check if the handle is valid? Is this a standard SafeHandle? If so, calling Dispose on an invalid handle can throw.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's a good idea. Updated.

@brianrob brianrob enabled auto-merge (squash) August 29, 2025 19:37
@brianrob brianrob merged commit 52cb563 into microsoft:main Aug 29, 2025
5 checks passed
@brianrob brianrob deleted the dev/brianrob/dispose-handles branch August 29, 2025 19:46
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.

2 participants