]> granicus.if.org Git - php/commitdiff
Add some missing DatePeriod initialization checks
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Aug 2020 15:18:50 +0000 (17:18 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Aug 2020 15:23:23 +0000 (17:23 +0200)
ext/date/php_date.c
ext/date/tests/oo_001.phpt

index d81bc1659a990c617cabc2398adfe51d99c926ec..0892439a0671b63609bbaf12a1bacf9b1a6b5736 100644 (file)
@@ -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);
index 1d8af7f933b24db3a2cf1716ecd29d0d9ed46190..2c06a2b45cdcba6ce69299d536ccb32a6be4bf84 100644 (file)
@@ -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