]> granicus.if.org Git - php/commitdiff
Fixed bug #67368 (Memory leak with immediately dereferenced array in class constant)
authorXinchen Hui <laruence@php.net>
Tue, 24 Jun 2014 05:53:05 +0000 (13:53 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 24 Jun 2014 05:53:05 +0000 (13:53 +0800)
NEWS
Zend/tests/bug67368.phpt [new file with mode: 0644]
Zend/zend_ast.c

diff --git a/NEWS b/NEWS
index 693486b889c542897763c5e670d58b5a55877102..373f810881684b5a4c9cda68f97ae7c9f8c7f301 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2014, PHP 5.6.0 Release Candidate 2
 
 - Core:
+  . Fixed bug #67368 (Memory leak with immediately dereferenced array in class
+    constant). (Laruence)
   . Fixed bug #67468 (Segfault in highlight_file()/highlight_string()).
     (Andreas Ferber)
 
diff --git a/Zend/tests/bug67368.phpt b/Zend/tests/bug67368.phpt
new file mode 100644 (file)
index 0000000..c92e994
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #67368 (Memory leak with immediately dereferenced array in class constant)
+--INI--
+report_memleaks=1
+--FILE--
+<?php
+class FooBar {
+               const bar = ["bar" => 3]["bar"];
+}
+echo "okey";
+--EXPECTF--
+okey
index 583a52321bee0551af463ab7beddcf50ec4dffc9..12f94055239a793cbe9b831690e918019c934d2a 100644 (file)
@@ -328,8 +328,7 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
                        {
                                zval *tmp;
                                zend_fetch_dimension_by_zval(&tmp, &op1, &op2 TSRMLS_CC);
-                               *result = *tmp;
-                               efree(tmp);
+                               ZVAL_ZVAL(result, tmp, 1, 1);
                        }
                        zval_dtor(&op1);
                        zval_dtor(&op2);