Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16f05e5

Browse files
committed
fix for "handle is not inialized" crash on clr.GetClrType(System.__class__)
1 parent 32ec24c commit 16f05e5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/runtime/managedtype.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33

44
namespace Python.Runtime
@@ -34,6 +34,10 @@ internal static ManagedType GetManagedObject(IntPtr ob)
3434
IntPtr op = tp == ob
3535
? Marshal.ReadIntPtr(tp, TypeOffset.magic())
3636
: Marshal.ReadIntPtr(ob, ObjectOffset.magic(ob));
37+
if (op == IntPtr.Zero)
38+
{
39+
return null;
40+
}
3741
var gc = (GCHandle)op;
3842
return (ManagedType)gc.Target;
3943
}

0 commit comments

Comments
 (0)