From: Dmitry Stogov Date: Wed, 5 Mar 2014 20:15:56 +0000 (+0400) Subject: Fixed support for undefined constants in RECV_INIT X-Git-Tag: POST_PHPNG_MERGE~412^2~409^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=018be97c0d324453e7505d62f4a39fd202089cce;p=php Fixed support for undefined constants in RECV_INIT --- diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 0d3637a937..02030ff413 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -531,17 +531,16 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope zend_error(E_ERROR, "Undefined constant '%s'", save->val); } if (inline_change) { -//??? STR_RELEASE(save); + STR_RELEASE(save); } save = NULL; } - if (inline_change && save && save->val != actual) { -//??? STR_RELEASE(save); - } zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); p->type = IS_STRING; if (!inline_change) { ZVAL_STRINGL(p, actual, actual_len); + } else if (save) { + STR_RELEASE(save); } } } else { diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 7d975deb67..30fefcdf97 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3376,12 +3376,30 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST) var_ptr = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); zval_ptr_dtor(var_ptr); if (param == NULL) { +//??? +#if 1 + if (IS_CONSTANT_TYPE(Z_TYPE_P(opline->op2.zv))) { + zval tmp; + + ZVAL_COPY_VALUE(&tmp, opline->op2.zv); + zval_update_constant(&tmp, 0 TSRMLS_CC); +//???: var_ptr may become INDIRECT + if (Z_TYPE_P(var_ptr) == IS_INDIRECT) { + var_ptr = Z_INDIRECT_P(var_ptr); + } + ZVAL_COPY_VALUE(var_ptr, &tmp); + } else { + ZVAL_COPY_VALUE(var_ptr, opline->op2.zv); + zval_copy_ctor(var_ptr); + } +#else ZVAL_COPY_VALUE(var_ptr, opline->op2.zv); if (IS_CONSTANT_TYPE(Z_TYPE_P(var_ptr))) { zval_update_constant(var_ptr, 0 TSRMLS_CC); } else { zval_copy_ctor(var_ptr); } +#endif } else { ZVAL_COPY(var_ptr, param); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 03e0276a60..12393aa379 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1603,12 +1603,30 @@ static int ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ var_ptr = _get_zval_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); zval_ptr_dtor(var_ptr); if (param == NULL) { +//??? +#if 1 + if (IS_CONSTANT_TYPE(Z_TYPE_P(opline->op2.zv))) { + zval tmp; + + ZVAL_COPY_VALUE(&tmp, opline->op2.zv); + zval_update_constant(&tmp, 0 TSRMLS_CC); +//???: var_ptr may become INDIRECT + if (Z_TYPE_P(var_ptr) == IS_INDIRECT) { + var_ptr = Z_INDIRECT_P(var_ptr); + } + ZVAL_COPY_VALUE(var_ptr, &tmp); + } else { + ZVAL_COPY_VALUE(var_ptr, opline->op2.zv); + zval_copy_ctor(var_ptr); + } +#else ZVAL_COPY_VALUE(var_ptr, opline->op2.zv); if (IS_CONSTANT_TYPE(Z_TYPE_P(var_ptr))) { zval_update_constant(var_ptr, 0 TSRMLS_CC); } else { zval_copy_ctor(var_ptr); } +#endif } else { ZVAL_COPY(var_ptr, param); }