]> granicus.if.org Git - php/commitdiff
Allowed indirect $this access (Scott)
authorDmitry Stogov <dmitry@php.net>
Wed, 1 Dec 2010 13:33:49 +0000 (13:33 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 1 Dec 2010 13:33:49 +0000 (13:33 +0000)
Zend/tests/indirect_reference_this.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/indirect_reference_this.phpt b/Zend/tests/indirect_reference_this.phpt
new file mode 100644 (file)
index 0000000..c344bd0
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Indirect referenced $this
+--FILE--
+<?php
+class X {
+  function f($x){var_dump($$x);}
+}
+$x = new X;
+$x->f("this");
+?>
+--EXPECTF--
+object(X)#%d (0) {
+}
index 9d61c004d6f4e31500528f10206eae47642d7de6..30f8f6d5a17563f264d36cd272f49ec35f0a5843 100644 (file)
@@ -5543,6 +5543,10 @@ void zend_do_indirect_references(znode *result, const znode *num_references, zno
        }
        zend_do_begin_variable_parse(TSRMLS_C);
        fetch_simple_variable(result, variable, 1 TSRMLS_CC);
+       /* there is a chance someone is accessing $this */
+       if (CG(active_op_array)->scope && CG(active_op_array)->this_var == -1) {
+               CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), estrndup("this", sizeof("this")-1), sizeof("this")-1);
+       }
 }
 /* }}} */