php-src/ext/date/tests/date_interval_bad_format_leak.phpt
Nikita Popov 988fc94bbb Fix leak on failed DatePeriod initialization
We need to free not only p here, but also b and e.
2020-08-27 12:54:43 +02:00

29 lines
603 B
PHP

--TEST--
DateInterval with bad format should not leak period
--FILE--
<?php
try {
$interval = new DateInterval('P3"D');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
$perid = new DatePeriod('P3"D');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
new DatePeriod('2008-03-01T12:00:00Z1');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
DateInterval::__construct(): Unknown or bad format (P3"D)
DatePeriod::__construct(): Unknown or bad format (P3"D)
DatePeriod::__construct(): Unknown or bad format (2008-03-01T12:00:00Z1)