Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/TraceEvent/EventPipe/EventPipeEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,9 +1111,9 @@ public EventPipeEventMetaDataHeader(PinnedStreamReader reader, int length, Event
{
if (_eventRecord != null)
{
if (_eventRecord->ExtendedData != null)
if (_extendedDataBuffer != IntPtr.Zero)
{
Marshal.FreeHGlobal((IntPtr)_eventRecord->ExtendedData);
Marshal.FreeHGlobal(_extendedDataBuffer);
}

Marshal.FreeHGlobal((IntPtr)_eventRecord);
Expand Down Expand Up @@ -1168,11 +1168,13 @@ public EventPipeEventMetaDataHeader(PinnedStreamReader reader, int length, Event
if (0 < stackBytesSize)
{
// Lazy allocation (destructor frees it).
if (_eventRecord->ExtendedData == null)
if (_extendedDataBuffer == IntPtr.Zero)
{
_eventRecord->ExtendedData = (TraceEventNativeMethods.EVENT_HEADER_EXTENDED_DATA_ITEM*)Marshal.AllocHGlobal(sizeof(TraceEventNativeMethods.EVENT_HEADER_EXTENDED_DATA_ITEM));
_extendedDataBuffer = Marshal.AllocHGlobal(sizeof(TraceEventNativeMethods.EVENT_HEADER_EXTENDED_DATA_ITEM));
}

_eventRecord->ExtendedData = (TraceEventNativeMethods.EVENT_HEADER_EXTENDED_DATA_ITEM*)_extendedDataBuffer;

if ((_eventRecord->EventHeader.Flags & TraceEventNativeMethods.EVENT_HEADER_FLAG_32_BIT_HEADER) != 0)
{
_eventRecord->ExtendedData->ExtType = TraceEventNativeMethods.EVENT_HEADER_EXT_TYPE_STACK_TRACE32;
Expand Down Expand Up @@ -1350,6 +1352,7 @@ public static Guid GetProviderGuidFromProviderName(string name)
}

private TraceEventNativeMethods.EVENT_RECORD* _eventRecord;
private IntPtr _extendedDataBuffer;
}

/// <summary>
Expand Down