[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

Daniel Scherzer <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Daniel Scherzer (DanielEScherzer)
Date: 2026-07-10T11:00:35-07:00

Commit: https://github.com/php/php-src/commit/0836518684d3efb18d170956065767a1c2342e8e
Raw diff: https://github.com/php/php-src/commit/0836518684d3efb18d170956065767a1c2342e8e.diff

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  NEWS
  GH-22658: avoid truncation on null bytes in `ReflectionConstant::__toString()`
  Add regression tests for `ReflectionConstant::__toString()` with null bytes

Changed paths:
  A  ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
  M  ext/reflection/php_reflection.c


Diff:

diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 956e6ea22d41..fc2e06d3b08c 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -616,7 +616,7 @@ static void _const_string(smart_str *str, const char *name, zval *value, const c
 	if (Z_TYPE_P(value) == IS_ARRAY) {
 		smart_str_append(str, ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED));
 	} else if (Z_TYPE_P(value) == IS_STRING) {
-		smart_str_appends(str, Z_STRVAL_P(value));
+		smart_str_append(str, Z_STR_P(value));
 	} else {
 		zend_string *tmp_value_str;
 		zend_string *value_str = zval_get_tmp_string(value, &tmp_value_str);
diff --git a/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
new file mode 100644
index 000000000000..8b6a8e85c2fc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
@@ -0,0 +1,14 @@
+--TEST--
+GH-22658: ReflectionConstant with a string value with a null byte
+--FILE--
+<?php
+
+define('DEMO', "f\0oo");
+$r = new ReflectionConstant('DEMO');
+echo $r;
+var_dump( $r->getValue() );
+
+?>
+--EXPECTF--
+Constant [ string DEMO ] { f%0oo }
+string(4) "f%0oo"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.