Skip to content

DatePeriod can crash if passed non initialized DateInterfaces #11416

Description

@arnaud-lb

Description

Found these while working on lazy objects.

The following code snippets result in crashes:

PHP Version

PHP 8.1

<?php

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
new DatePeriod($date, new DateInterval('P1D'), 2);

PHP Version

PHP 8.2

<?php

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
$dateperiod = (new ReflectionClass(DatePeriod::class))->newInstanceWithoutConstructor();
$dateperiod->__unserialize(['start' => $date]); // __wakeup is also affected

Operating System

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions