Skip to content

Commit 98a8b23

Browse files
committed
Bug 1842810: Handle number overflow in AddTimeDaysSlow. r=spidermonkey-reviewers,mgaudet
This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814 UltraBlame original commit: 8941d99e1eb17454a255df18d412ab32963d6aae
1 parent b60e054 commit 98a8b23

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed

js/src/builtin/temporal/PlainDateTime.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,14 @@ weeks
42504250
daysResult
42514251
}
42524252
;
4253+
MOZ_ASSERT
4254+
(
4255+
IsValidDuration
4256+
(
4257+
duration
4258+
)
4259+
)
4260+
;
42534261
/
42544262
/
42554263
Step

js/src/builtin/temporal/PlainTime.cpp

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8855,8 +8855,42 @@ return
88558855
false
88568856
;
88578857
}
8858-
*
8859-
result
8858+
/
8859+
/
8860+
The
8861+
days
8862+
number
8863+
is
8864+
used
8865+
as
8866+
the
8867+
input
8868+
for
8869+
a
8870+
duration
8871+
.
8872+
Throw
8873+
if
8874+
the
8875+
BigInt
8876+
/
8877+
/
8878+
when
8879+
converted
8880+
to
8881+
a
8882+
Number
8883+
can
8884+
'
8885+
t
8886+
be
8887+
represented
8888+
in
8889+
a
8890+
duration
8891+
.
8892+
double
8893+
daysNumber
88608894
=
88618895
BigInt
88628896
:
@@ -8866,6 +8900,38 @@ numberValue
88668900
days
88678901
)
88688902
;
8903+
if
8904+
(
8905+
!
8906+
ThrowIfInvalidDuration
8907+
(
8908+
cx
8909+
{
8910+
0
8911+
0
8912+
0
8913+
daysNumber
8914+
}
8915+
)
8916+
)
8917+
{
8918+
return
8919+
false
8920+
;
8921+
}
8922+
MOZ_ASSERT
8923+
(
8924+
IsInteger
8925+
(
8926+
daysNumber
8927+
)
8928+
)
8929+
;
8930+
*
8931+
result
8932+
=
8933+
daysNumber
8934+
;
88698935
return
88708936
true
88718937
;
@@ -9850,6 +9916,14 @@ return
98509916
false
98519917
;
98529918
}
9919+
MOZ_ASSERT
9920+
(
9921+
IsInteger
9922+
(
9923+
days
9924+
)
9925+
)
9926+
;
98539927
*
98549928
result
98559929
=

0 commit comments

Comments
 (0)