Skip to content

Commit e6b2a97

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #72941: Modifying bucket->data by-ref has no effect any longer
2 parents ababa22 + 5dcb8f2 commit e6b2a97

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ PHP NEWS
3131
- Standard:
3232
. Fixed bug #79986 (str_ireplace bug with diacritics characters). (cmb)
3333
. Fixed bug #80077 (getmxrr test bug). (Rainer Jung)
34+
. Fixed bug #72941 (Modifying bucket->data by-ref has no effect any longer).
35+
(cmb)
3436

3537
03 Sep 2020, PHP 7.4.10
3638

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Bug #72941 (Modifying bucket->data by-ref has no effect any longer)
3+
--FILE--
4+
<?php
5+
class rotate_filter_nw extends php_user_filter
6+
{
7+
function filter($in, $out, &$consumed, $closing)
8+
{
9+
while ($bucket = stream_bucket_make_writeable($in)) {
10+
$this->rotate($bucket->data);
11+
$consumed += $bucket->datalen;
12+
stream_bucket_prepend($out, $bucket);
13+
}
14+
15+
return PSFS_PASS_ON;
16+
}
17+
18+
function rotate(&$data)
19+
{
20+
$n = strlen($data);
21+
for ($i = 0; $i < $n - 1; ++$i) {
22+
$data[$i] = $data[$i + 1];
23+
}
24+
}
25+
}
26+
27+
stream_filter_register("rotator_notWorking", rotate_filter_nw::class);
28+
$stream = fopen('php://memory', 'w+');
29+
fwrite($stream, 'hello, world');
30+
rewind($stream);
31+
stream_filter_append($stream, "rotator_notWorking");
32+
var_dump(stream_get_contents($stream));
33+
?>
34+
--EXPECT--
35+
string(12) "ello, worldd"

ext/standard/user_filters.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
435435
Z_PARAM_OBJECT(zobject)
436436
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
437437

438-
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
438+
if (NULL == (pzbucket = zend_hash_str_find_deref(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
439439
php_error_docref(NULL, E_WARNING, "Object has no bucket property");
440440
RETURN_FALSE;
441441
}
@@ -449,7 +449,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
449449
RETURN_FALSE;
450450
}
451451

452-
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
452+
if (NULL != (pzdata = zend_hash_str_find_deref(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
453453
if (!bucket->own_buf) {
454454
bucket = php_stream_bucket_make_writeable(bucket);
455455
}

0 commit comments

Comments
 (0)