Fix TimeSpan overflow on Read (#6170)

A lot of areas use TimeSpan.MaxValue but when saved and read the current time is added which results in an overflow.
A check is now performed to prevent this.
This commit is contained in:
John
2025-08-29 18:59:39 -04:00
committed by GitHub
parent fee79d8aa5
commit fb0ec52f8c

View File

@@ -37,7 +37,13 @@ public sealed class TimeOffsetSerializer : ITypeSerializer<TimeSpan, ValueDataNo
var timing = ctx.Timing;
var seconds = double.Parse(node.Value, CultureInfo.InvariantCulture);
return TimeSpan.FromSeconds(seconds) + timing.CurTime;
var time = TimeSpan.FromSeconds(seconds);
// Checks if adding time and curTime will overflow.
if(time > TimeSpan.MaxValue - timing.CurTime)
return TimeSpan.MaxValue;
return time + timing.CurTime;
}
public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node,