浏览代码

Adding null check to prevent null reference exception when serializing delegates in C#

Alexander Schill 2 年之前
父节点
当前提交
5f47873f10
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs

+ 5 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs

@@ -76,6 +76,11 @@ namespace Godot
 
         internal static bool TrySerializeDelegate(Delegate @delegate, Collections.Array serializedData)
         {
+            if (@delegate is null)
+            {
+                return false;
+            }
+
             if (@delegate is MulticastDelegate multicastDelegate)
             {
                 bool someDelegatesSerialized = false;