Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Fix #72941: Modifying bucket->data by-ref has no effect any longer
This commit is contained in:
Christoph M. Becker 2020-09-08 18:07:57 +02:00
commit e6b2a97cac
3 changed files with 39 additions and 2 deletions

2
NEWS
View File

@ -31,6 +31,8 @@ PHP NEWS
- Standard:
. Fixed bug #79986 (str_ireplace bug with diacritics characters). (cmb)
. Fixed bug #80077 (getmxrr test bug). (Rainer Jung)
. Fixed bug #72941 (Modifying bucket->data by-ref has no effect any longer).
(cmb)
03 Sep 2020, PHP 7.4.10

View File

@ -0,0 +1,35 @@
--TEST--
Bug #72941 (Modifying bucket->data by-ref has no effect any longer)
--FILE--
<?php
class rotate_filter_nw extends php_user_filter
{
function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$this->rotate($bucket->data);
$consumed += $bucket->datalen;
stream_bucket_prepend($out, $bucket);
}
return PSFS_PASS_ON;
}
function rotate(&$data)
{
$n = strlen($data);
for ($i = 0; $i < $n - 1; ++$i) {
$data[$i] = $data[$i + 1];
}
}
}
stream_filter_register("rotator_notWorking", rotate_filter_nw::class);
$stream = fopen('php://memory', 'w+');
fwrite($stream, 'hello, world');
rewind($stream);
stream_filter_append($stream, "rotator_notWorking");
var_dump(stream_get_contents($stream));
?>
--EXPECT--
string(12) "ello, worldd"

View File

@ -435,7 +435,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
Z_PARAM_OBJECT(zobject)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
if (NULL == (pzbucket = zend_hash_str_find_deref(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
php_error_docref(NULL, E_WARNING, "Object has no bucket property");
RETURN_FALSE;
}
@ -449,7 +449,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
if (NULL != (pzdata = zend_hash_str_find_deref(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
if (!bucket->own_buf) {
bucket = php_stream_bucket_make_writeable(bucket);
}