diff options
| author | Nikita Popov <nikic@php.net> | 2016-04-20 18:43:43 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2016-04-20 18:43:43 +0200 |
| commit | c9d8dfed60e6a7140fd6e34db6ab1ebe8ba66557 (patch) | |
| tree | 41baa5d3c85a2896a03f8b8df8a0899e509d7b90 | |
| parent | 02e6808144830d0a029c53e7e73f79a93d26a669 (diff) | |
| parent | 77bb96d7c95ddfdba8b16325db439913ee58522f (diff) | |
| download | php-git-c9d8dfed60e6a7140fd6e34db6ab1ebe8ba66557.tar.gz | |
Merge branch 'PHP-7.0'
| -rw-r--r-- | Zend/tests/bug41117_1.phpt | 3 | ||||
| -rw-r--r-- | Zend/tests/bug71737.phpt | 16 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 5 |
3 files changed, 20 insertions, 4 deletions
diff --git a/Zend/tests/bug41117_1.phpt b/Zend/tests/bug41117_1.phpt index f555b637ad..a612f07fed 100644 --- a/Zend/tests/bug41117_1.phpt +++ b/Zend/tests/bug41117_1.phpt @@ -10,5 +10,4 @@ class foo { $obj = new foo("Hello world"); ?> --EXPECTF-- -Fatal error: Cannot re-assign $this in %sbug41117_1.php on line 3 - +Fatal error: Cannot use $this as parameter in %s on line %d diff --git a/Zend/tests/bug71737.phpt b/Zend/tests/bug71737.phpt new file mode 100644 index 0000000000..b44de8e78e --- /dev/null +++ b/Zend/tests/bug71737.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #71737: Memory leak in closure with parameter named $this +--FILE-- +<?php + +class Test { + public function method() { + return function($this) {}; + } +} + +(new Test)->method()(new stdClass); + +?> +--EXPECTF-- +Fatal error: Cannot use $this as parameter in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index fe9139b609..11eb04040b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4903,8 +4903,9 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter $%s", ZSTR_VAL(name)); } else if (zend_string_equals_literal(name, "this")) { - if (op_array->scope && (op_array->fn_flags & ZEND_ACC_STATIC) == 0) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this"); + if ((op_array->scope || (op_array->fn_flags & ZEND_ACC_CLOSURE)) + && (op_array->fn_flags & ZEND_ACC_STATIC) == 0) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as parameter"); } op_array->this_var = var_node.u.op.var; } |
