From aa9825aad965879fae2dab9afd1a86564f856fe9 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Tue, 16 Apr 2019 20:12:12 -0700 Subject: [PATCH] Fix incorrect EHCount calculation (#24048) --- .../src/System/Reflection/Emit/DynamicILGenerator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs index fb763a5..d26d97d 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -724,7 +724,12 @@ namespace System.Reflection.Emit if ((header & 0x40) != 0) // Fat { - EHCount = (BinaryPrimitives.ReadInt32LittleEndian(m_exceptionHeader.AsSpan(1)) - 4) / 24; + // Positions 1..3 of m_exceptionHeader are a 24-bit little-endian integer. + int size = m_exceptionHeader[3] << 16; + size |= m_exceptionHeader[2] << 8; + size |= m_exceptionHeader[1]; + + EHCount = (size - 4) / 24; } else EHCount = (m_exceptionHeader[1] - 2) / 12; -- 2.7.4