com php-src: Fix bug #71525: ext/date/php_date.c ext/date /tests/bug71525.phpt
| From: | Anatol Belski | Date: | Mon, 15 Feb 2016 07:19:07 +0000 |
| Subject: | com php-src: Fix bug #71525: ext/date/php_date.c ext/date /tests/bug71525.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91041@lists.php.net to get a copy of this message | ||
Commit: f31e0cd3345ab1d0b4a5f82a804b2a8868a307e1
Author: Sean DuBois <sean@siobud.com> Thu, 4 Feb 2016 15:13:57 -0600
Committer: Anatol Belski <ab@php.net> Mon, 15 Feb 2016 08:19:07 +0100
Parents: d0649a8441f6087a63d2aba0f4b9fe045ba29a1c
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f31e0cd3345ab1d0b4a5f82a804b2a8868a307e1
Log:
Fix bug #71525
timelib_time->timelib_rel_time is mutated by date_modify, and because it is never zero'ed
out
it latters causes other date operations to fail (like date_date_set)
Bugs:
https://bugs.php.net/71525
Changed paths:
M ext/date/php_date.c
A ext/date/tests/bug71525.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 2c548ae..2fe78a0 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -3054,6 +3054,7 @@ static int php_date_modify(zval *object, char *modify, size_t modify_len) /*
{{{
timelib_update_ts(dateobj->time, NULL);
timelib_update_from_sse(dateobj->time);
dateobj->time->have_relative = 0;
+ memset(&dateobj->time->relative, 0, sizeof(dateobj->time->relative));
return 1;
} /* }}} */
diff --git a/ext/date/tests/bug71525..phpt b/ext/date/tests/bug71525.phpt
new file mode 100644
index 0000000...dadf926
--- /dev/null
+++ b/ext/date/tests/bug71525.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #71525 (Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues)
+--FILE--
+<?php
+$date = new DateTime('2011-12-25 00:00:00');
+$date->modify('first day of next month');
+$date->setDate('2012', '1', '29');
+var_dump($date);
+
+--EXPECTF--
+object(DateTime)#%d (3) {
+ ["date"]=>
+ string(26) "2012-01-29 00:00:00.000000"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
+}