From e656a72f0ea45aebdbd8424719072ed15633c0fe Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 2 Oct 2024 13:32:24 +0200 Subject: [PATCH] fix edge case of reading 0 bytes from BufferedStream --- src/Stream/BufferedStream.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Stream/BufferedStream.php b/src/Stream/BufferedStream.php index cf23fc7..289ff8c 100644 --- a/src/Stream/BufferedStream.php +++ b/src/Stream/BufferedStream.php @@ -170,6 +170,9 @@ public function read(int $length): string if ($length < 0) { throw new \InvalidArgumentException('Can not read a negative amount of bytes'); } + if (0 === $length) { + return ''; + } $read = '';