Skip to content

Commit a7edde7

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 1feb210 + 0ee170b commit a7edde7

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ext/calendar/dow.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@
3333
int DayOfWeek(
3434
zend_long sdn)
3535
{
36-
int dow;
37-
38-
dow = (sdn + 1) % 7;
39-
if (dow >= 0) {
40-
return (dow);
41-
} else {
42-
return (dow + 7);
43-
}
36+
return (int)(sdn % 7 + 8) % 7;
4437
}
4538

4639
const char * const DayNameShort[7] =

ext/calendar/tests/gh16258.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-16258 (jddayofweek overflow on argument)
3+
--EXTENSIONS--
4+
calendar
5+
--FILE--
6+
<?php
7+
jddayofweek(PHP_INT_MAX, 1);
8+
jddayofweek(PHP_INT_MIN, 1);
9+
echo "DONE";
10+
?>
11+
--EXPECT--
12+
DONE

0 commit comments

Comments
 (0)