Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 011eeca

Browse files
dotnet-botstephentoub
authored andcommitted
Initialize stack allocated data structures. (dotnet/coreclr#16259) (#26943)
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent ee7d459 commit 011eeca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Common/src/CoreLib/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ private unsafe void WriteMultiMergeInner(
434434
var pinCount = eventTypes.pinCount;
435435
var scratch = stackalloc byte[eventTypes.scratchSize];
436436
var descriptors = stackalloc EventData[eventTypes.dataCount + 3];
437+
for(int i = 0; i < eventTypes.dataCount + 3; i++)
438+
descriptors[i] = default(EventData);
437439

438440
var pins = stackalloc GCHandle[pinCount];
439441
for (int i = 0; i < pinCount; i++)
@@ -538,7 +540,10 @@ internal unsafe void WriteMultiMerge(
538540

539541
// We make a descriptor for each EventData, and because we morph strings to counted strings
540542
// we may have 2 for each arg, so we allocate enough for this.
541-
var descriptors = stackalloc EventData[eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3];
543+
var descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3;
544+
var descriptors = stackalloc EventData[descriptorsLength];
545+
for(int i = 0; i < descriptorsLength; i++)
546+
descriptors[i] = default(EventData);
542547

543548
fixed (byte*
544549
pMetadata0 = this.providerMetadata,
@@ -614,6 +619,8 @@ private unsafe void WriteImpl(
614619
var pinCount = eventTypes.pinCount;
615620
var scratch = stackalloc byte[eventTypes.scratchSize];
616621
var descriptors = stackalloc EventData[eventTypes.dataCount + 3];
622+
for(int i=0; i<eventTypes.dataCount + 3; i++)
623+
descriptors[i] = default(EventData);
617624

618625
var pins = stackalloc GCHandle[pinCount];
619626
for (int i = 0; i < pinCount; i++)

0 commit comments

Comments
 (0)