Skip to content

Commit ccb6642

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #81294: Segfault when removing a filter
2 parents 1bd6faf + bf9afc1 commit ccb6642

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #81294 (Segfault when removing a filter)
3+
--EXTENSIONS--
4+
zlib
5+
--FILE--
6+
<?php
7+
$f = fopen(__DIR__ . "/bug81294.txt", "wb+");
8+
$flt1 = stream_filter_append($f, "zlib.deflate", STREAM_FILTER_WRITE);
9+
$flt2 = stream_filter_append($f, "string.rot13", STREAM_FILTER_WRITE);
10+
fwrite($f, "test");
11+
stream_filter_remove($flt1);
12+
fwrite($f, "test");
13+
stream_filter_remove($flt2);
14+
rewind($f);
15+
var_dump(urlencode(fread($f, 1024)));
16+
?>
17+
--CLEAN--
18+
<?php
19+
@unlink(__DIR__ . "/bug81294.txt");
20+
?>
21+
--EXPECT--
22+
string(16) "%2BV-.%01%00grfg"

main/streams/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
416416
for(current = filter; current; current = current->next) {
417417
php_stream_filter_status_t status;
418418

419-
status = filter->fops->filter(stream, current, inp, outp, NULL, flags);
419+
status = current->fops->filter(stream, current, inp, outp, NULL, flags);
420420
if (status == PSFS_FEED_ME) {
421421
/* We've flushed the data far enough */
422422
return SUCCESS;

0 commit comments

Comments
 (0)