Created
January 6, 2024 21:07
-
-
Save nielsdos/d4cc1fbc3db1abe88f517919b2ad61e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main/streams/streams.c b/main/streams/streams.c | |
index e1399927b2..d45a9bfab8 100644 | |
--- a/main/streams/streams.c | |
+++ b/main/streams/streams.c | |
@@ -1133,8 +1133,15 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz | |
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position); | |
} | |
+ /* See GH-13071: userspace stream is subject to the memory limit. */ | |
+ size_t chunk_size = count; | |
+ if (php_stream_is(stream, PHP_STREAM_IS_USERSPACE)) { | |
+ /* If the stream is unbuffered, we can only write one byte at a time. */ | |
+ chunk_size = stream->chunk_size; | |
+ } | |
+ | |
while (count > 0) { | |
- ssize_t justwrote = stream->ops->write(stream, buf, count); | |
+ ssize_t justwrote = stream->ops->write(stream, buf, MIN(chunk_size, count)); | |
if (justwrote <= 0) { | |
/* If we already successfully wrote some bytes and a write error occurred | |
* later, report the successfully written bytes. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment