[php-src] master: Zend: assert that refcounted zval in zval_internal_ptr_dtor is a string (#23592)

From: Date: Sun, 06 Sep 2026 18:11:25 +0000
Subject: [php-src] master: Zend: assert that refcounted zval in zval_internal_ptr_dtor is a string (#23592)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141098@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Committer: GitHub (web-flow) Pusher: Girgias Date: 2026-09-06T19:11:22+01:00 Commit: https://github.com/php/php-src/commit/735a38f1839b02548a44e92426c3feaf2a02d1a4 Raw diff: https://github.com/php/php-src/commit/735a38f1839b02548a44e92426c3feaf2a02d1a4.diff Zend: assert that refcounted zval in zval_internal_ptr_dtor is a string (#23592) Changed paths: M Zend/zend_variables.c Diff: diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 02c286ac486a..1ee84ce5c7a1 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -101,19 +101,16 @@ ZEND_API void zval_ptr_safe_dtor(zval *zval_ptr) ZEND_API void zval_internal_ptr_dtor(zval *zval_ptr) /* {{{ */ { if (Z_REFCOUNTED_P(zval_ptr)) { + ZEND_ASSERT(Z_TYPE_P(zval_ptr) == IS_STRING && "Internal zval's can't be arrays, objects, resources or reference"); zend_refcounted *ref = Z_COUNTED_P(zval_ptr); if (GC_DELREF(ref) == 0) { - if (Z_TYPE_P(zval_ptr) == IS_STRING) { - zend_string *str = (zend_string*)ref; - - CHECK_ZVAL_STRING(str); - ZEND_ASSERT(!ZSTR_IS_INTERNED(str)); - ZEND_ASSERT((GC_FLAGS(str) & IS_STR_PERSISTENT)); - free(str); - } else { - zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects, resources or reference"); - } + zend_string *str = (zend_string*)ref; + + CHECK_ZVAL_STRING(str); + ZEND_ASSERT(!ZSTR_IS_INTERNED(str)); + ZEND_ASSERT((GC_FLAGS(str) & IS_STR_PERSISTENT)); + free(str); } } }

« previous php.cvs (#141098) next »