Fix an integer overflow in Islamic calendar

When the time is set to MAX_MILLIS, Islamic calendar
year and month calculation results in an integer overflow.

TBR=littledan@chromium.org
Bug: 801602
Test: See the bug (v8 test will be added)
Change-Id: Ifcb6907de81de83b690f76a536818054815a15a7
Reviewed-on: https://chromium-review.googlesource.com/865524
Reviewed-by: Jungshik Shin <jshin@chromium.org>
diff --git a/README.chromium b/README.chromium
index 66a5745..221078f 100644
--- a/README.chromium
+++ b/README.chromium
@@ -280,5 +280,9 @@
 8. Reduce size of SmallIntFormatter implementation
 
   - patches/simplify_smallintformatter.patch
-  Reduce the size of the binary by about 16 kiB on Android,
-  without noticeable performance change.
+    upstream bug: https://ssl.icu-project.org/trac/ticket/12390
+
+9. Fix an integer overflow in Islamic calendar
+
+  - patches/islamcal.patch
+    upstream bug: https://ssl.icu-project.org/trac/ticket/13538
diff --git a/patches/islamcal.patch b/patches/islamcal.patch
new file mode 100644
index 0000000..f190ed2
--- /dev/null
+++ b/patches/islamcal.patch
@@ -0,0 +1,13 @@
+diff --git a/source/i18n/islamcal.cpp b/source/i18n/islamcal.cpp
+index 4fd0e07d..de100242 100644
+--- a/source/i18n/islamcal.cpp
++++ b/source/i18n/islamcal.cpp
+@@ -614,7 +614,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
+             days = julianDay - ASTRONOMICAL_EPOC;
+         }
+         // Use the civil calendar approximation, which is just arithmetic
+-        year  = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 );
++        year  = (int32_t)ClockMath::floorDivide( (double)(30 * (int64_t) days + 10646) , 10631.0 );
+         month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
+         month = month<11?month:11;
+         startDate = monthStart(year, month);
diff --git a/source/i18n/islamcal.cpp b/source/i18n/islamcal.cpp
index 4fd0e07..de10024 100644
--- a/source/i18n/islamcal.cpp
+++ b/source/i18n/islamcal.cpp
@@ -614,7 +614,7 @@
             days = julianDay - ASTRONOMICAL_EPOC;
         }
         // Use the civil calendar approximation, which is just arithmetic
-        year  = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 );
+        year  = (int32_t)ClockMath::floorDivide( (double)(30 * (int64_t) days + 10646) , 10631.0 );
         month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
         month = month<11?month:11;
         startDate = monthStart(year, month);