Skip to content

Commit 6a32cf3

Browse files
committed
ICU-23305 Fix int64_t overflow in doParse
1 parent 9f1c574 commit 6a32cf3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

icu4c/source/i18n/nfsubs.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,10 +1343,18 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
13431343
int64_t n = result.getLong(status); // force conversion!
13441344
int64_t d = 1;
13451345
while (d <= n) {
1346+
if (d > U_INT64_MAX / 10) {
1347+
// Will cause int64_t overflow
1348+
return false;
1349+
}
13461350
d *= 10;
13471351
}
13481352
// now add the zeros
13491353
while (zeroCount > 0) {
1354+
if (d > U_INT64_MAX / 10) {
1355+
// Will cause int64_t overflow
1356+
return false;
1357+
}
13501358
d *= 10;
13511359
--zeroCount;
13521360
}

0 commit comments

Comments
 (0)