1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-19705: do not flush/write buffer on non writeable stream.

Co-authored-by: Jakub Zelenka <bukka@php.net>

close GH-19708
This commit is contained in:
David Carlier
2025-09-04 18:38:38 +01:00
parent 26ca363a13
commit 175afc4085
3 changed files with 14 additions and 1 deletions

2
NEWS
View File

@@ -57,6 +57,8 @@ PHP NEWS
. Fixed bug GH-19248 (Use strerror_r instead of strerror in main).
(Jakub Zelenka)
. Fixed bug GH-17345 (Bug #35916 was not completely fixed). (nielsdos)
. Fixed bug GH-19705 (segmentation when attempting to flush on non seekable
stream. (bukka/David Carlier)
- XMLReader:
. Fixed bug GH-20009 (XMLReader leak on RelaxNG schema failure). (nielsdos)

View File

@@ -0,0 +1,11 @@
--TEST--
GH-19705 segmentation fault with non writable stream at stream_filter_append call.
--EXTENSIONS--
zlib
--FILE--
<?php
$fh = fopen('data://text/plain,', 'w+',);
var_dump(stream_filter_append($fh, 'zlib.deflate',STREAM_FILTER_WRITE));
?>
--EXPECTF--
resource(%d) of type (stream filter)

View File

@@ -1295,7 +1295,7 @@ PHPAPI int _php_stream_flush(php_stream *stream, int closing)
{
int ret = 0;
if (stream->writefilters.head) {
if (stream->writefilters.head && stream->ops->write) {
_php_stream_write_filtered(stream, NULL, 0, closing ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC );
}