Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #81294: Segfault when removing a filter #7308

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions ext/standard/tests/filters/bug81294.phpt
@@ -0,0 +1,24 @@
--TEST--
Bug #81294 (Segfault when removing a filter)
--SKIPIF--
<?php
if (!extension_loaded('zlib')) die("skip zlib extension not available");
?>
--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"
2 changes: 1 addition & 1 deletion main/streams/filter.c
Expand Up @@ -418,7 +418,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;
Expand Down