]> granicus.if.org Git - php/commitdiff
Fix usages of zend_update_constant_ex
authorNikita Popov <nikic@php.net>
Fri, 29 Apr 2016 12:04:23 +0000 (14:04 +0200)
committerNikita Popov <nikic@php.net>
Fri, 29 Apr 2016 12:06:39 +0000 (14:06 +0200)
If an in-place update in an external zval is performed, it needs
to incref'd beforehand, not afterwards.

Zend/zend_execute_API.c
Zend/zend_ini_parser.y
ext/reflection/php_reflection.c
ext/standard/basic_functions.c

index 6bb833fd997a4ec38872659a962e00cc95f5e8db..2acf29c2ce99bbab1ce915bb48e8065d7776e2ee 100644 (file)
@@ -646,12 +646,6 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */
                                zend_string_release(Z_STR_P(p));
                        }
                        ZVAL_COPY_VALUE(p, const_value);
-                       if (Z_OPT_CONSTANT_P(p)) {
-                               if (UNEXPECTED(zval_update_constant_ex(p, scope) != SUCCESS)) {
-                                       RESET_CONSTANT_VISITED(p);
-                                       return FAILURE;
-                               }
-                       }
                        zval_opt_copy_ctor(p);
                }
        } else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
index 315455bf8872dbf77ddb364f8ca2877a9db7b539..ed047c0c2a20853a5e8033e9725f682338a2e0ae 100644 (file)
@@ -132,11 +132,10 @@ static void zend_ini_get_constant(zval *result, zval *name)
        if (!memchr(Z_STRVAL_P(name), ':', Z_STRLEN_P(name))
                        && (c = zend_get_constant(Z_STR_P(name))) != 0) {
                if (Z_TYPE_P(c) != IS_STRING) {
-                       ZVAL_COPY_VALUE(&tmp, c);
+                       ZVAL_COPY(&tmp, c);
                        if (Z_OPT_CONSTANT(tmp)) {
                                zval_update_constant_ex(&tmp, NULL);
                        }
-                       zval_opt_copy_ctor(&tmp);
                        convert_to_string(&tmp);
                        c = &tmp;
                }
index b4bd65182a2e7dd14d1b596c2047cfdaabeafaf3..d6186271783c7ab62ec494d0a77a1922ec2d768d 100644 (file)
@@ -2884,11 +2884,9 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
                return;
        }
 
-       ZVAL_COPY_VALUE(return_value, RT_CONSTANT(&param->fptr->op_array, precv->op2));
+       ZVAL_COPY(return_value, RT_CONSTANT(&param->fptr->op_array, precv->op2));
        if (Z_CONSTANT_P(return_value)) {
                zval_update_constant_ex(return_value, param->fptr->common.scope);
-       } else {
-               zval_copy_ctor(return_value);
        }
 }
 /* }}} */
index 0481e41a6e33ea2e6e135ec0f6acce3161d8028f..dcd0b0fa2783474c86c533c01c61526c37711d3f 100644 (file)
@@ -3843,13 +3843,12 @@ PHP_FUNCTION(constant)
        scope = zend_get_executed_scope();
        c = zend_get_constant_ex(const_name, scope, ZEND_FETCH_CLASS_SILENT);
        if (c) {
-               ZVAL_COPY_VALUE(return_value, c);
+               ZVAL_COPY(return_value, c);
                if (Z_CONSTANT_P(return_value)) {
                        if (UNEXPECTED(zval_update_constant_ex(return_value, scope) != SUCCESS)) {
                                return;
                        }
                }
-               zval_copy_ctor(return_value);
        } else {
                php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", ZSTR_VAL(const_name));
                RETURN_NULL();