summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/php_date.c2
-rw-r--r--ext/date/tests/bug67118.phpt17
-rw-r--r--ext/date/tests/bug67118_2.phpt28
3 files changed, 38 insertions, 9 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 37266d17b5..aaa3afa04b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2529,6 +2529,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
}
if (err && err->error_count) {
+ timelib_time_dtor(dateobj->time);
+ dateobj->time = 0;
return 0;
}
diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt
index 6371757647..2aa8c1d828 100644
--- a/ext/date/tests/bug67118.phpt
+++ b/ext/date/tests/bug67118.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #67118 php-cgi crashes regularly on IIS 7
+Bug #67118 crashes in DateTime when this used after failed __construct
--INI--
date.timezone=Europe/Berlin
--FILE--
@@ -11,17 +11,16 @@ class mydt extends datetime
if (!empty($tz) && !is_object($tz)) {
$tz = new DateTimeZone($tz);
}
-
- @parent::__construct($time, $tz);
+ try {
+ @parent::__construct($time, $tz);
+ } catch (Exception $e) {
+ echo "Bad date" . $this->format("Y") . "\n";
+ }
}
};
new mydt("Funktionsansvarig rÄdgivning och juridik", "UTC");
+?>
--EXPECTF--
-Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (Funktionsansvarig rÄdgivning och juridik) at position 0 (F): The timezone could not be found in the database' in %sbug67118.php:%d
-Stack trace:
-#0 %sbug67118.php(%d): DateTime->__construct('Funktionsansvar...', Object(DateTimeZone))
-#1 %sbug67118.php(%d): mydt->__construct('Funktionsansvar...', 'UTC')
-#2 {main}
- thrown in %sbug67118.php on line %d
+Fatal error: Call to a member function format() on a non-object in %sbug67118.php on line %d
diff --git a/ext/date/tests/bug67118_2.phpt b/ext/date/tests/bug67118_2.phpt
new file mode 100644
index 0000000000..368d4d9401
--- /dev/null
+++ b/ext/date/tests/bug67118_2.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Regression introduce in fix for Bug #67118 - Invalid code
+--INI--
+date.timezone=Europe/Paris
+--FILE--
+<?php
+class Foo extends DateTime {
+ public function __construct($time = null) {
+ $tz = new DateTimeZone('UTC');
+ try {
+ echo "First try\n";
+ parent::__construct($time, $tz);
+ return;
+ } catch (Exception $e) {
+ echo "Second try\n";
+ parent::__construct($time.'C', $tz);
+ }
+ }
+}
+$date = '12 Sep 2007 15:49:12 UT';
+var_dump(new Foo($date));
+?>
+Done
+--EXPECTF--
+First try
+Second try
+NULL
+Done \ No newline at end of file