diff options
author | Derick Rethans <github@derickrethans.nl> | 2019-04-17 09:40:28 +0100 |
---|---|---|
committer | Derick Rethans <github@derickrethans.nl> | 2019-04-17 09:40:28 +0100 |
commit | 4a3f64dfeff28c3df7ddb644f72f4548aec9d391 (patch) | |
tree | 7a842532b5e0ac8cd0e31e443fa57c3456be8ae3 /ext | |
parent | 346ac968b3de89263d5692a7558626b566858c9d (diff) | |
parent | 6088713216a176267c8eababbbd33736840028a6 (diff) | |
download | php-git-4a3f64dfeff28c3df7ddb644f72f4548aec9d391.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
Diffstat (limited to 'ext')
-rw-r--r-- | ext/date/php_date.c | 4 | ||||
-rw-r--r-- | ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c80e318b22..03fdc18284 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4646,6 +4646,10 @@ PHP_METHOD(DatePeriod, __construct) dpobj->end = clone; } } + + if (dpobj->end == NULL && recurrences < 1) { + php_error_docref(NULL, E_WARNING, "The recurrence count '%d' is invalid. Needs to be > 0", (int) recurrences); + } /* options */ dpobj->include_start_date = !(options & PHP_DATE_PERIOD_EXCLUDE_START_DATE); diff --git a/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt b/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt new file mode 100644 index 0000000000..715ea63dc9 --- /dev/null +++ b/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt @@ -0,0 +1,19 @@ +--TEST-- +DatePeriod: Test wrong recurrence parameter on __construct +--FILE-- +<?php +try { + new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), 0); +} catch (Exception $exception) { + echo $exception->getMessage(), "\n"; +} + +try { + new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'),-1); +} catch (Exception $exception) { + echo $exception->getMessage(), "\n"; +} +?> +--EXPECTF-- +DatePeriod::__construct(): The recurrence count '0' is invalid. Needs to be > 0 +DatePeriod::__construct(): The recurrence count '-1' is invalid. Needs to be > 0 |