فهرست منبع

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)
         internal static bool TrySerializeDelegate(Delegate @delegate, Collections.Array serializedData)
         {
         {
+            if (@delegate is null)
+            {
+                return false;
+            }
+
             if (@delegate is MulticastDelegate multicastDelegate)
             if (@delegate is MulticastDelegate multicastDelegate)
             {
             {
                 bool someDelegatesSerialized = false;
                 bool someDelegatesSerialized = false;