From 0384673554d9a81c6658a735886e31264d0bcef3 Mon Sep 17 00:00:00 2001 From: Brian Robbins Date: Wed, 7 Feb 2018 14:47:25 -0800 Subject: [PATCH] Initialize stack allocated data structures. (dotnet/coreclr#16259) Signed-off-by: dotnet-bot --- .../Tracing/TraceLogging/TraceLoggingEventSource.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs index bf29d71844e..bf717fb56cc 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs @@ -438,6 +438,8 @@ private unsafe void WriteMultiMergeInner( var pinCount = eventTypes.pinCount; var scratch = stackalloc byte[eventTypes.scratchSize]; var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; + for(int i = 0; i < eventTypes.dataCount + 3; i++) + descriptors[i] = default(EventData); var pins = stackalloc GCHandle[pinCount]; for (int i = 0; i < pinCount; i++) @@ -542,7 +544,10 @@ internal unsafe void WriteMultiMerge( // We make a descriptor for each EventData, and because we morph strings to counted strings // we may have 2 for each arg, so we allocate enough for this. - var descriptors = stackalloc EventData[eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3]; + var descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3; + var descriptors = stackalloc EventData[descriptorsLength]; + for(int i = 0; i < descriptorsLength; i++) + descriptors[i] = default(EventData); fixed (byte* pMetadata0 = this.providerMetadata, @@ -618,6 +623,8 @@ private unsafe void WriteImpl( var pinCount = eventTypes.pinCount; var scratch = stackalloc byte[eventTypes.scratchSize]; var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; + for(int i=0; i