Merge branch 'PHP-8.0'

* PHP-8.0:
  Fix #81294: Segfault when removing a filter
This commit is contained in:
Christoph M. Becker 2021-07-27 12:15:59 +02:00
commit ccb6642c91
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,22 @@
--TEST--
Bug #81294 (Segfault when removing a filter)
--EXTENSIONS--
zlib
--FILE--
<?php
$f = fopen(__DIR__ . "/bug81294.txt", "wb+");
$flt1 = stream_filter_append($f, "zlib.deflate", STREAM_FILTER_WRITE);
$flt2 = stream_filter_append($f, "string.rot13", STREAM_FILTER_WRITE);
fwrite($f, "test");
stream_filter_remove($flt1);
fwrite($f, "test");
stream_filter_remove($flt2);
rewind($f);
var_dump(urlencode(fread($f, 1024)));
?>
--CLEAN--
<?php
@unlink(__DIR__ . "/bug81294.txt");
?>
--EXPECT--
string(16) "%2BV-.%01%00grfg"

View file

@ -416,7 +416,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
for(current = filter; current; current = current->next) {
php_stream_filter_status_t status;
status = filter->fops->filter(stream, current, inp, outp, NULL, flags);
status = current->fops->filter(stream, current, inp, outp, NULL, flags);
if (status == PSFS_FEED_ME) {
/* We've flushed the data far enough */
return SUCCESS;