Skip to content

Commit 1a00ed0

Browse files
committed
Fix OverflowException on 64bit due to bad cast
Error message was `OverflowException occurred. Arithmetic operation resulted in an overflow.` Link below explains in more detail the issue. This fixes the issue in both 32/64bit. https://www.codeproject.com/Answers/899343/How-to-fix-OverflowException-occurred-Arithmetic-o#answer2
1 parent d7942c8 commit 1a00ed0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime/managedtype.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal static ManagedType GetManagedObject(IntPtr ob)
2828
tp = ob;
2929
}
3030

31-
var flags = (int)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
31+
var flags = (Int64)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
3232
if ((flags & TypeFlags.Managed) != 0)
3333
{
3434
IntPtr op = tp == ob
@@ -63,7 +63,7 @@ internal static bool IsManagedType(IntPtr ob)
6363
tp = ob;
6464
}
6565

66-
var flags = (int)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
66+
var flags = (Int64)Marshal.ReadIntPtr(tp, TypeOffset.tp_flags);
6767
if ((flags & TypeFlags.Managed) != 0)
6868
{
6969
return true;

0 commit comments

Comments
 (0)