From 5f47873f1064defc0f2c3ad7163812a19f58d707 Mon Sep 17 00:00:00 2001 From: Alexander Schill Date: Tue, 11 Oct 2022 09:22:52 +0200 Subject: Adding null check to prevent null reference exception when serializing delegates in C# --- modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/mono/glue/GodotSharp') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs index 3c75d18943..9b3969d453 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs +++ b/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; -- cgit v1.2.3