From: Mike McLaughlin Date: Tue, 20 Sep 2022 22:25:21 +0000 (-0700) Subject: Fix overflow exception in Microsoft.Diagnostics.Monitoring (#3400) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055542~51^2~1^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d820d51bdbd61b3d89d6c459715997a0c5c1def;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix overflow exception in Microsoft.Diagnostics.Monitoring (#3400) Issue: https://github.com/dotnet/diagnostics/issues/3392 --- diff --git a/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs b/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs index e9f61ce2d..7280bbdb3 100644 --- a/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs +++ b/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs @@ -882,35 +882,38 @@ namespace Graphs internal static void WriteCompressedInt(SegmentedMemoryStreamWriter writer, int value) { - if (value << 25 >> 25 == value) + unchecked { - goto oneByte; - } + if (value << 25 >> 25 == value) + { + goto oneByte; + } - if (value << 18 >> 18 == value) - { - goto twoBytes; - } + if (value << 18 >> 18 == value) + { + goto twoBytes; + } - if (value << 11 >> 11 == value) - { - goto threeBytes; - } + if (value << 11 >> 11 == value) + { + goto threeBytes; + } - if (value << 4 >> 4 == value) - { - goto fourBytes; - } + if (value << 4 >> 4 == value) + { + goto fourBytes; + } - writer.Write((byte)((value >> 28) | 0x80)); + writer.Write((byte)((value >> 28) | 0x80)); fourBytes: - writer.Write((byte)((value >> 21) | 0x80)); + writer.Write((byte)((value >> 21) | 0x80)); threeBytes: - writer.Write((byte)((value >> 14) | 0x80)); + writer.Write((byte)((value >> 14) | 0x80)); twoBytes: - writer.Write((byte)((value >> 7) | 0x80)); + writer.Write((byte)((value >> 7) | 0x80)); oneByte: - writer.Write((byte)(value & 0x7F)); + writer.Write((byte)(value & 0x7F)); + } } internal NodeIndex m_index;