Skip to content

Commit f11c1fa

Browse files
committed
date: Fix typo in condition in date_period_init_iso8601_string()
Now the address is being checked instead of the value, but I believe the value should be checked against 0, not the pointer against NULL. Closes GH-22253.
1 parent 61a1b9a commit f11c1fa

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed issues with oversized allocations and signed overflow in bcround()
77
and BcMath\Number::round(). (edorian)
88

9+
- Date:
10+
. Fix incorrect recurrence check of DatePeriod::createFromISO8601String().
11+
(ndossche)
12+
913
- GD:
1014
. Fixed bug GH-22121 (Double free in gdImageSetStyle() after
1115
overflow-triggered early return). (iliaal)

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5125,7 +5125,7 @@ static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_en
51255125
zend_string_release(func);
51265126
return false;
51275127
}
5128-
if (dpobj->end == NULL && recurrences == 0) {
5128+
if (dpobj->end == NULL && *recurrences == 0) {
51295129
zend_string *func = get_active_function_or_method_name();
51305130
zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr);
51315131
zend_string_release(func);

ext/date/tests/date_period_bad_iso_format.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must
5050
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
5151

5252
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
53-
DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
54-
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
53+
DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must contain an end date or a recurrence count, "2012-07-01T00:00:00Z/P7D" given
54+
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an end date or a recurrence count, "2012-07-01T00:00:00Z/P7D" given

0 commit comments

Comments
 (0)