Bug #67274 [Com]: DateTime constructor crash with invalid data
| From: | arjen at react dot com | Date: | Fri, 20 Jun 2014 10:00:33 +0000 |
| Subject: | Bug #67274 [Com]: DateTime constructor crash with invalid data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186273@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67274&edit=1
ID: 67274
Comment by: arjen at react dot com
Reported by: arjen at react dot com
Summary: DateTime constructor crash with invalid data
Status: Open
Type: Bug
Package: Date/time related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Fixed in in 5.6.0rc1: http://3v4l.org/FeE0n#v560rc1
Commit in https://bugs.php.net/bug.php?id=67118
Previous Comments:
------------------------------------------------------------------------
[2014-05-14 09:23:32] arjen at react dot com
Description:
------------
Only partially solved in https://bugs.php.net/bug.php?id=67118
$this is unset (see https://bugs.php.net/bug.php?id=67179 for bug about
this) but corrupted internal state still intact. Catching exception and calling parent::format()
results in a segfault.
See http://3v4l.org/FeE0n#v536
Test script:
---------------
<?php
class DateTimeCustom extends DateTime
{
public function __construct($datetime, $timezone = null)
{
try
{
parent::__construct($datetime, $timezone);
}
catch (Exception $e)
{
var_dump($this, parent::getLastErrors(), parent::format('c'));
}
}
}
$date = new DateTimeCustom("sunday 09 blabla 2001 103:46:40 CEST");
Expected result:
----------------
Result for 5.3.0 - 5.3.5 is expected:
Warning: DateTime::format(): The DateTime object has not been correctly initialized by its
constructor in /in/FeE0n on line 15
object(DateTimeCustom)#1 (0) {
}
bool(false)
bool(false)
Actual result:
--------------
Segfault.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67274&edit=1