summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/date/tests/bug49700.phpt15
3 files changed, 19 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 1841663245..02e29d4d81 100644
--- a/NEWS
+++ b/NEWS
@@ -69,6 +69,8 @@ PHP NEWS
- Fixed bug #50358 (Compile failure compiling ext/phar/util.lo). (Felipe)
- Fixed bug #49778 (DateInterval::format("%a") is always zero when an interval
is created from an ISO string). (Derick)
+- Fixed bug #49700 (memory leaks in php_date.c if garbage collector is
+ enabled). (Dmitry)
- Fixed bug #49576 (FILTER_VALIDATE_EMAIL filter needs updating) (Rasmus)
- Fixed bug #49429 (odbc_autocommit doesn't work). (Felipe)
- Fixed bug #49234 (mysqli_ssl_set not found). (Andrey)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 0cc86feeb7..07cfcec2fb 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2081,7 +2081,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
props = dateobj->std.properties;
- if (!dateobj->time) {
+ if (!dateobj->time || GC_G(gc_active)) {
return props;
}
@@ -2224,7 +2224,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
props = intervalobj->std.properties;
- if (!intervalobj->initialized) {
+ if (!intervalobj->initialized || GC_G(gc_active)) {
return props;
}
diff --git a/ext/date/tests/bug49700.phpt b/ext/date/tests/bug49700.phpt
new file mode 100644
index 0000000000..a347052593
--- /dev/null
+++ b/ext/date/tests/bug49700.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #49700 (memory leaks in php_date.c if garbage collector is enabled)
+--INI--
+date.timezone=GMT
+--FILE--
+<?php
+gc_enable();
+$objs = array();
+$objs[1] = new DateTime();
+gc_collect_cycles();
+unset($objs);
+echo "OK\n";
+?>
+--EXPECT--
+OK