Skip to content

Commit 18afd6b

Browse files
committed
Add null checks before binding
1 parent 3b6500f commit 18afd6b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/runtime/ClassManager.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,13 @@ internal static void InitClassBase(Type type, ClassBase impl, ReflectedClrType p
288288
Runtime.PyType_Modified(pyType.Reference);
289289
}
290290

291-
internal static bool ShouldBindMethod(MethodBase mb)
292-
{
293-
return (mb.IsPublic || mb.IsFamily || mb.IsFamilyOrAssembly);
294-
}
291+
internal static bool ShouldBindMethod(MethodBase mb) =>
292+
mb != null &&
293+
(mb.IsPublic || mb.IsFamily || mb.IsFamilyOrAssembly);
295294

296-
internal static bool ShouldBindField(FieldInfo fi)
297-
{
298-
return (fi.IsPublic || fi.IsFamily || fi.IsFamilyOrAssembly);
299-
}
295+
internal static bool ShouldBindField(FieldInfo fi) =>
296+
fi != null &&
297+
(fi.IsPublic || fi.IsFamily || fi.IsFamilyOrAssembly);
300298

301299
internal static bool ShouldBindProperty(PropertyInfo pi)
302300
{

0 commit comments

Comments
 (0)