diff options
author | Tomas Weinfurt <tweinfurt@yahoo.com> | 2019-01-09 02:53:35 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2019-01-09 02:53:35 -0800 |
commit | 3c81b68ca399f16077c159e838da38968494f3a7 (patch) | |
tree | 6fb133089fa796153ea3bd8a0abe2a0e9ddd4b0e /src | |
parent | c119bd7fae8359fe49e9234ae47315ca74c7dea1 (diff) | |
download | coreclr-3c81b68ca399f16077c159e838da38968494f3a7.tar.gz coreclr-3c81b68ca399f16077c159e838da38968494f3a7.tar.bz2 coreclr-3c81b68ca399f16077c159e838da38968494f3a7.zip |
fix DateTime overflow on ARM32 (#21902)
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/DateTime.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/System.Private.CoreLib/shared/System/DateTime.cs b/src/System.Private.CoreLib/shared/System/DateTime.cs index c0210b0741..a94171f133 100644 --- a/src/System.Private.CoreLib/shared/System/DateTime.cs +++ b/src/System.Private.CoreLib/shared/System/DateTime.cs @@ -455,10 +455,12 @@ namespace System // time units to this DateTime. private DateTime Add(double value, int scale) { - long millis = (long)(value * scale + (value >= 0 ? 0.5 : -0.5)); - if (millis <= -MaxMillis || millis >= MaxMillis) - throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_AddValue); - return AddTicks(millis * TicksPerMillisecond); + double millis_double = value * (double)scale + (value >= 0 ? 0.5 : -0.5); + + if (millis_double <= (double)-MaxMillis || millis_double >= (double)MaxMillis) + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_AddValue); + + return AddTicks((long)millis_double * TicksPerMillisecond); } // Returns the DateTime resulting from adding a fractional number of |