From 05600fb09717cea7d060c76b0ea1c93bbad1e2f2 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Mon, 30 Sep 2024 18:45:00 -0400 Subject: [PATCH] handle infinity --- src/Engine/ProtoCore/FFI/CLRObjectMarshaler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Engine/ProtoCore/FFI/CLRObjectMarshaler.cs b/src/Engine/ProtoCore/FFI/CLRObjectMarshaler.cs index 7649b913b24..85be1041613 100644 --- a/src/Engine/ProtoCore/FFI/CLRObjectMarshaler.cs +++ b/src/Engine/ProtoCore/FFI/CLRObjectMarshaler.cs @@ -159,6 +159,11 @@ public override StackValue Marshal(object obj, ProtoCore.Runtime.Context context public override object UnMarshal(StackValue dsObject, ProtoCore.Runtime.Context context, Interpreter dsi, Type type) { + if (double.IsInfinity(dsObject.DoubleValue)) + { + return CastToDouble(dsObject.DoubleValue); + } + if (dsObject.DoubleValue > MaxValue || dsObject.DoubleValue < MinValue || double.IsNaN(dsObject.DoubleValue)) { string message = String.Format(Resources.kFFIInvalidCast, dsObject.DoubleValue, type.Name, MinValue, MaxValue);