]> granicus.if.org Git - php/commitdiff
Merge branch 'master' into phpng
authorDmitry Stogov <dmitry@zend.com>
Wed, 23 Jul 2014 21:54:21 +0000 (01:54 +0400)
committerDmitry Stogov <dmitry@zend.com>
Wed, 23 Jul 2014 21:54:21 +0000 (01:54 +0400)
* master:
  Removed second zval_copy_ctor()
  Fixed crash on self-referencing constant expression (part of a constant AST)
  Fixed support for constant arrays in context of "const" statement (Zend/tests/constant_expressions_arrays.phpt failed when opcache.protect_memort was set)

Conflicts:
Zend/zend_ast.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/reflection/php_reflection.c

1  2 
Zend/zend_ast.c
ext/reflection/php_reflection.c

diff --cc Zend/zend_ast.c
index e173afd2f9de9a7d2dea3923dfd3688c35d0cf0e,54448ac286265b9f1d1737eb01b2586e96e3765a..824c0d5c3e4dc27d285a4718ba8e89aeeb250eac
@@@ -282,9 -251,19 +282,17 @@@ ZEND_API void zend_ast_evaluate(zval *r
                        zval_dtor(&op2);
                        break;
                case ZEND_CONST:
-                       ZVAL_DUP(result, &ast->u.val);
-                       if (Z_OPT_CONSTANT_P(result)) {
-                               zval_update_constant_ex(result, 1, scope TSRMLS_CC);
+                       /* class constants may be updated in-place */
+                       if (scope) {
 -                              if (IS_CONSTANT_TYPE(Z_TYPE_P(ast->u.val))) {
++                              if (Z_OPT_CONSTANT(ast->u.val)) {
+                                       zval_update_constant_ex(&ast->u.val, 1, scope TSRMLS_CC);
+                               }
 -                              *result = *ast->u.val;
 -                              zval_copy_ctor(result);
++                              ZVAL_DUP(result, &ast->u.val);
+                       } else {
 -                              *result = *ast->u.val;
 -                              zval_copy_ctor(result);
 -                              if (IS_CONSTANT_TYPE(Z_TYPE_P(result))) {
 -                                      zval_update_constant_ex(&result, 1, scope TSRMLS_CC);
++                              ZVAL_DUP(result, &ast->u.val);
++                              if (Z_OPT_CONSTANT_P(result)) {
++                                      zval_update_constant_ex(result, 1, scope TSRMLS_CC);
+                               }
                        }
                        break;
                case ZEND_BOOL_AND:
index 724754295177a956d89655cd3e4dbe6b0bb74fd8,02a19c0aaabee2af509226d0606143a39bd1c1fe..f2d3059c3d2ec952be3f41a22b290ae1e70fd924
@@@ -721,20 -726,31 +721,25 @@@ static void _parameter_string(string *s
        if (fptr->type == ZEND_USER_FUNCTION && offset >= required) {
                zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
                if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
 -                      zval *zv, zv_copy;
 -                      int use_copy;
 +                      zval zv;
+                       zend_class_entry *old_scope;
                        string_write(str, " = ", sizeof(" = ")-1);
 -                      ALLOC_ZVAL(zv);
 -                      *zv = *precv->op2.zv;
 -                      zval_copy_ctor(zv);
 -                      INIT_PZVAL(zv);
 +                      ZVAL_DUP(&zv, precv->op2.zv);
-                       zval_update_constant_ex(&zv, 1, fptr->common.scope TSRMLS_CC);
+                       old_scope = EG(scope);
+                       EG(scope) = fptr->common.scope;
+                       zval_update_constant_ex(&zv, 1, NULL TSRMLS_CC);
+                       EG(scope) = old_scope;
 -                      if (Z_TYPE_P(zv) == IS_BOOL) {
 -                              if (Z_LVAL_P(zv)) {
 -                                      string_write(str, "true", sizeof("true")-1);
 -                              } else {
 -                                      string_write(str, "false", sizeof("false")-1);
 -                              }
 -                      } else if (Z_TYPE_P(zv) == IS_NULL) {
 +                      if (Z_TYPE(zv) == IS_TRUE) {
 +                              string_write(str, "true", sizeof("true")-1);
 +                      } else if (Z_TYPE(zv) == IS_FALSE) {
 +                              string_write(str, "false", sizeof("false")-1);
 +                      } else if (Z_TYPE(zv) == IS_NULL) {
                                string_write(str, "NULL", sizeof("NULL")-1);
 -                      } else if (Z_TYPE_P(zv) == IS_STRING) {
 +                      } else if (Z_TYPE(zv) == IS_STRING) {
                                string_write(str, "'", sizeof("'")-1);
 -                              string_write(str, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 15));
 -                              if (Z_STRLEN_P(zv) > 15) {
 +                              string_write(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15));
 +                              if (Z_STRLEN(zv) > 15) {
                                        string_write(str, "...", sizeof("...")-1);
                                }
                                string_write(str, "'", sizeof("'")-1);
@@@ -2576,12 -2600,15 +2581,16 @@@ ZEND_METHOD(reflection_parameter, getDe
                return;
        }
  
 -      *return_value = *precv->op2.zv;
 -      INIT_PZVAL(return_value);
 -      if (!IS_CONSTANT_TYPE(Z_TYPE_P(return_value))) {
 +      ZVAL_COPY_VALUE(return_value, precv->op2.zv);
 +      if (Z_CONSTANT_P(return_value)) {
-               zval_update_constant_ex(return_value, 0, param->fptr->common.scope TSRMLS_CC);
++              zend_class_entry *old_scope = EG(scope);
++
++              EG(scope) = param->fptr->common.scope;
++              zval_update_constant_ex(return_value, 0, NULL TSRMLS_CC);
++              EG(scope) = old_scope;
 +      } else {
                zval_copy_ctor(return_value);
        }
 -      old_scope = EG(scope);
 -      EG(scope) = param->fptr->common.scope;
 -      zval_update_constant_ex(&return_value, 0, NULL TSRMLS_CC);
 -      EG(scope) = old_scope;
  }
  /* }}} */