Skip to content

Commit f98f27f

Browse files
committed
MFB: Fix for bug #22199
1 parent d1d0d0b commit f98f27f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main/streams.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,17 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
869869
justwrote = stream->ops->write(stream, buf, towrite TSRMLS_CC);
870870
}
871871
if (justwrote > 0) {
872-
stream->position += justwrote;
873872
buf += justwrote;
874873
count -= justwrote;
875874
didwrite += justwrote;
876875

877-
/* FIXME: invalidate the whole readbuffer */
878-
stream->writepos = 0;
879-
stream->readpos = 0;
876+
/* Only screw with the buffer if we can seek, otherwise we lose data
877+
* buffered from fifos and sockets */
878+
if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
879+
stream->position += justwrote;
880+
stream->writepos = 0;
881+
stream->readpos = 0;
882+
}
880883
} else {
881884
break;
882885
}

0 commit comments

Comments
 (0)