From 615f5e8cd55a56ca4abb3589e30bfc36d359e873 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 9 Nov 2025 14:36:22 +0100 Subject: [PATCH 1/2] Zend: Remove useless zval & dtor from define() --- Zend/zend_builtin_functions.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index eab2a03990112..b6b69db4bc78d 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -555,7 +555,7 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */ ZEND_FUNCTION(define) { zend_string *name; - zval *val, val_free; + zval *val; bool non_cs = 0; zend_constant c; @@ -575,8 +575,6 @@ ZEND_FUNCTION(define) zend_error(E_WARNING, "define(): Argument #3 ($case_insensitive) is ignored since declaration of case-insensitive constants is no longer supported"); } - ZVAL_UNDEF(&val_free); - if (Z_TYPE_P(val) == IS_ARRAY) { if (Z_REFCOUNTED_P(val)) { if (!validate_constant_array_argument(Z_ARRVAL_P(val), 2)) { @@ -589,7 +587,6 @@ ZEND_FUNCTION(define) } ZVAL_COPY(&c.value, val); - zval_ptr_dtor(&val_free); register_constant: /* non persistent */ From b4189d04f1387fb67a836ab4d6fc551bbac9f352 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 9 Nov 2025 14:37:14 +0100 Subject: [PATCH 2/2] Zend: Get rid of goto in define() --- Zend/zend_builtin_functions.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index b6b69db4bc78d..ca1a84631b250 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -575,20 +575,16 @@ ZEND_FUNCTION(define) zend_error(E_WARNING, "define(): Argument #3 ($case_insensitive) is ignored since declaration of case-insensitive constants is no longer supported"); } - if (Z_TYPE_P(val) == IS_ARRAY) { - if (Z_REFCOUNTED_P(val)) { - if (!validate_constant_array_argument(Z_ARRVAL_P(val), 2)) { - RETURN_THROWS(); - } else { - copy_constant_array(&c.value, val); - goto register_constant; - } + if (Z_TYPE_P(val) == IS_ARRAY && Z_REFCOUNTED_P(val)) { + if (!validate_constant_array_argument(Z_ARRVAL_P(val), 2)) { + RETURN_THROWS(); + } else { + copy_constant_array(&c.value, val); } + } else { + ZVAL_COPY(&c.value, val); } - ZVAL_COPY(&c.value, val); - -register_constant: /* non persistent */ ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT); c.name = zend_string_copy(name);