@@ -291,10 +291,10 @@ static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */
291
291
}
292
292
/* }}} */
293
293
294
- static int lookup_cv (zend_op_array * op_array , char * name , int name_len TSRMLS_DC ) /* {{{ */
294
+ static int lookup_cv (zend_op_array * op_array , char * name , int name_len , ulong hash TSRMLS_DC ) /* {{{ */
295
295
{
296
296
int i = 0 ;
297
- ulong hash_value = zend_inline_hash_func (name , name_len + 1 );
297
+ ulong hash_value = hash ? hash : zend_inline_hash_func (name , name_len + 1 );
298
298
299
299
while (i < op_array -> last_var ) {
300
300
if (op_array -> vars [i ].name == name ||
@@ -642,7 +642,7 @@ void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar
642
642
(CG (active_op_array )-> last == 0 ||
643
643
CG (active_op_array )-> opcodes [CG (active_op_array )-> last - 1 ].opcode != ZEND_BEGIN_SILENCE )) {
644
644
result -> op_type = IS_CV ;
645
- result -> u .op .var = lookup_cv (CG (active_op_array ), varname -> u .constant .value .str .val , varname -> u .constant .value .str .len TSRMLS_CC );
645
+ result -> u .op .var = lookup_cv (CG (active_op_array ), varname -> u .constant .value .str .val , varname -> u .constant .value .str .len , 0 TSRMLS_CC );
646
646
varname -> u .constant .value .str .val = CG (active_op_array )-> vars [result -> u .op .var ].name ;
647
647
result -> EA = 0 ;
648
648
return ;
@@ -882,6 +882,7 @@ static zend_bool opline_is_fetch_this(const zend_op *opline TSRMLS_DC) /* {{{ */
882
882
{
883
883
if ((opline -> opcode == ZEND_FETCH_W ) && (opline -> op1_type == IS_CONST )
884
884
&& (Z_TYPE (CONSTANT (opline -> op1 .constant )) == IS_STRING )
885
+ && (Z_HASH_P (& CONSTANT (opline -> op1 .constant )) == THIS_HASHVAL )
885
886
&& (Z_STRLEN (CONSTANT (opline -> op1 .constant )) == (sizeof ("this" )- 1 ))
886
887
&& !memcmp (Z_STRVAL (CONSTANT (opline -> op1 .constant )), "this" , sizeof ("this" ))) {
887
888
return 1 ;
@@ -1290,7 +1291,7 @@ void zend_do_end_variable_parse(znode *variable, int type, int arg_offset TSRMLS
1290
1291
1291
1292
this_var = opline_ptr -> result .var ;
1292
1293
if (CG (active_op_array )-> this_var == -1 ) {
1293
- CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), Z_STRVAL (CONSTANT (opline_ptr -> op1 .constant )), Z_STRLEN (CONSTANT (opline_ptr -> op1 .constant )) TSRMLS_CC );
1294
+ CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), Z_STRVAL (CONSTANT (opline_ptr -> op1 .constant )), Z_STRLEN (CONSTANT (opline_ptr -> op1 .constant )), Z_HASH_P ( & CONSTANT ( opline_ptr -> op1 . constant )) TSRMLS_CC );
1294
1295
Z_TYPE (CONSTANT (opline_ptr -> op1 .constant )) = IS_NULL ;
1295
1296
} else {
1296
1297
zend_del_literal (CG (active_op_array ), opline_ptr -> op1 .constant );
@@ -1302,7 +1303,7 @@ void zend_do_end_variable_parse(znode *variable, int type, int arg_offset TSRMLS
1302
1303
variable -> u .op .var = CG (active_op_array )-> this_var ;
1303
1304
}
1304
1305
} else if (CG (active_op_array )-> this_var == -1 ) {
1305
- CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), estrndup ("this" , sizeof ("this" )- 1 ), sizeof ("this" )- 1 TSRMLS_CC );
1306
+ CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), estrndup ("this" , sizeof ("this" )- 1 ), sizeof ("this" )- 1 , THIS_HASHVAL TSRMLS_CC );
1306
1307
}
1307
1308
}
1308
1309
@@ -1810,10 +1811,11 @@ void zend_do_receive_arg(zend_uchar op, znode *varname, const znode *offset, con
1810
1811
zend_error (E_COMPILE_ERROR , "Cannot re-assign auto-global variable %s" , Z_STRVAL (varname -> u .constant ));
1811
1812
} else {
1812
1813
var .op_type = IS_CV ;
1813
- var .u .op .var = lookup_cv (CG (active_op_array ), varname -> u .constant .value .str .val , varname -> u .constant .value .str .len TSRMLS_CC );
1814
+ var .u .op .var = lookup_cv (CG (active_op_array ), varname -> u .constant .value .str .val , varname -> u .constant .value .str .len , 0 TSRMLS_CC );
1814
1815
varname -> u .constant .value .str .val = CG (active_op_array )-> vars [var .u .op .var ].name ;
1815
1816
var .EA = 0 ;
1816
- if (Z_STRLEN (varname -> u .constant ) == sizeof ("this" )- 1 &&
1817
+ if (CG (active_op_array )-> vars [var .u .op .var ].hash_value == THIS_HASHVAL &&
1818
+ Z_STRLEN (varname -> u .constant ) == sizeof ("this" )- 1 &&
1817
1819
!memcmp (Z_STRVAL (varname -> u .constant ), "this" , sizeof ("this" )- 1 )) {
1818
1820
if (CG (active_op_array )-> scope &&
1819
1821
(CG (active_op_array )-> fn_flags & ZEND_ACC_STATIC ) == 0 ) {
@@ -2699,7 +2701,7 @@ void zend_do_begin_catch(znode *try_token, znode *class_name, znode *catch_var,
2699
2701
opline -> op1_type = IS_CONST ;
2700
2702
opline -> op1 .constant = zend_add_class_name_literal (CG (active_op_array ), & catch_class .u .constant TSRMLS_CC );
2701
2703
opline -> op2_type = IS_CV ;
2702
- opline -> op2 .var = lookup_cv (CG (active_op_array ), catch_var -> u .constant .value .str .val , catch_var -> u .constant .value .str .len TSRMLS_CC );
2704
+ opline -> op2 .var = lookup_cv (CG (active_op_array ), catch_var -> u .constant .value .str .val , catch_var -> u .constant .value .str .len , 0 TSRMLS_CC );
2703
2705
catch_var -> u .constant .value .str .val = CG (active_op_array )-> vars [opline -> op2 .var ].name ;
2704
2706
opline -> result .num = 0 ; /* 1 means it's the last catch in the block */
2705
2707
@@ -5642,7 +5644,7 @@ void zend_do_indirect_references(znode *result, const znode *num_references, zno
5642
5644
fetch_simple_variable (result , variable , 1 TSRMLS_CC );
5643
5645
/* there is a chance someone is accessing $this */
5644
5646
if (CG (active_op_array )-> scope && CG (active_op_array )-> this_var == -1 ) {
5645
- CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), estrndup ("this" , sizeof ("this" )- 1 ), sizeof ("this" )- 1 TSRMLS_CC );
5647
+ CG (active_op_array )-> this_var = lookup_cv (CG (active_op_array ), estrndup ("this" , sizeof ("this" )- 1 ), sizeof ("this" )- 1 , THIS_HASHVAL TSRMLS_CC );
5646
5648
}
5647
5649
}
5648
5650
/* }}} */
0 commit comments