summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-13 17:18:50 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-13 17:23:23 +0200
commite40c9d49184d2ce93392a09033dbe5193d36e55f (patch)
tree090b6275d986ebe59d9c0f8252157782a8a9e6d4
parent8f61854108a916938095eccaad078b9c53078d4d (diff)
downloadphp-git-e40c9d49184d2ce93392a09033dbe5193d36e55f.tar.gz
Add some missing DatePeriod initialization checks
-rw-r--r--ext/date/php_date.c2
-rw-r--r--ext/date/tests/oo_001.phpt18
2 files changed, 20 insertions, 0 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index d81bc1659a..0892439a06 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4189,6 +4189,7 @@ PHP_METHOD(DatePeriod, getStartDate)
ZEND_PARSE_PARAMETERS_NONE();
dpobj = Z_PHPPERIOD_P(ZEND_THIS);
+ DATE_CHECK_INITIALIZED(dpobj->start, DatePeriod);
php_date_instantiate(dpobj->start_ce, return_value);
dateobj = Z_PHPDATE_P(return_value);
@@ -4239,6 +4240,7 @@ PHP_METHOD(DatePeriod, getDateInterval)
ZEND_PARSE_PARAMETERS_NONE();
dpobj = Z_PHPPERIOD_P(ZEND_THIS);
+ DATE_CHECK_INITIALIZED(dpobj->interval, DatePeriod);
php_date_instantiate(date_ce_interval, return_value);
diobj = Z_PHPINTERVAL_P(return_value);
diff --git a/ext/date/tests/oo_001.phpt b/ext/date/tests/oo_001.phpt
index 1d8af7f933..2c06a2b45c 100644
--- a/ext/date/tests/oo_001.phpt
+++ b/ext/date/tests/oo_001.phpt
@@ -11,6 +11,10 @@ class _t extends DateTimeZone {
function __construct() {
}
}
+class _p extends DatePeriod {
+ function __construct() {
+ }
+}
$d = new DateTime;
var_dump($d->format("Y-m-d H:i:s"));
@@ -44,6 +48,18 @@ try {
echo $e->getMessage(),"\n";
}
+$p = new _p;
+try {
+ var_dump($p->getStartDate());
+} catch (Error $e) {
+ echo $e->getMessage(),"\n";
+}
+try {
+ var_dump($p->getDateInterval());
+} catch (Error $e) {
+ echo $e->getMessage(),"\n";
+}
+
echo "DONE\n";
?>
--EXPECTF--
@@ -53,4 +69,6 @@ DateTime::__construct(): Failed to parse time string (1am todax) at position 4 (
string(3) "UTC"
The DateTimeZone object has not been correctly initialized by its constructor
DateTimeZone::__construct(): Unknown or bad timezone (GottaFindThisOne)
+The DatePeriod object has not been correctly initialized by its constructor
+The DatePeriod object has not been correctly initialized by its constructor
DONE