Skip to content

Commit 7861be9

Browse files
committed
changes from feedback
1 parent be4c4ea commit 7861be9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ext/calendar/jewish.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ static void MoladOfMetonicCycle(
439439
r1 = NEW_MOON_OF_CREATION;
440440
chk = (zend_long)metonicCycle;
441441

442-
if (chk > ((ZEND_LONG_MAX / (HALAKIM_PER_METONIC_CYCLE & 0xFFFF)) - NEW_MOON_OF_CREATION) ||
443-
chk > (((ZEND_LONG_MAX / ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF))) - (NEW_MOON_OF_CREATION >> 16))) {
442+
if (chk > (ZEND_LONG_MAX - NEW_MOON_OF_CREATION) / (HALAKIM_PER_METONIC_CYCLE & 0xFFFF)) {
444443
*pMoladDay = 0;
445444
*pMoladHalakim = 0;
446445
return;
@@ -450,6 +449,13 @@ static void MoladOfMetonicCycle(
450449
* bits of the result will be in r2 and the lower 16 bits will be
451450
* in r1. */
452451
r1 += chk * (HALAKIM_PER_METONIC_CYCLE & 0xFFFF);
452+
453+
if (chk > (ZEND_LONG_MAX - (r1 >> 16)) / ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF)) {
454+
*pMoladDay = 0;
455+
*pMoladHalakim = 0;
456+
return;
457+
}
458+
453459
r2 = r1 >> 16;
454460
r2 += chk * ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF);
455461

0 commit comments

Comments
 (0)