Skip to content

Commit

Permalink
Fix $this CV init for include/eval
Browse files Browse the repository at this point in the history
Fixes bug #68148
  • Loading branch information
nikic committed Oct 5, 2014
1 parent 9bc14f9 commit 58f3897
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
17 changes: 17 additions & 0 deletions Zend/tests/bug68148.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #68148: $this is null inside include
--FILE--
<?php

class Test {
public function method() {
eval('var_dump($this);');
}
}

(new Test)->method();

?>
--EXPECT--
object(Test)#1 (0) {
}
13 changes: 9 additions & 4 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,11 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu

zend_attach_symbol_table(execute_data);

if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
GC_REFCOUNT(Z_OBJ(EX(This)))++;
}

if (!op_array->run_time_cache && op_array->last_cache_slot) {
op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
}
Expand Down Expand Up @@ -1573,11 +1578,11 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
var++;
} while (var != end);
}
}

if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
GC_REFCOUNT(Z_OBJ(EX(This)))++;
}
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
GC_REFCOUNT(Z_OBJ(EX(This)))++;
}

if (!op_array->run_time_cache && op_array->last_cache_slot) {
Expand Down

0 comments on commit 58f3897

Please sign in to comment.