hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 7d81e7f873e8afb49256275918f8f1905203e73d
parent d39b6f22cb55f94418a7907ef593635a750a6072
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Fri,  6 May 2022 11:27:29 +0200

bufio::fixed: fix empty writes exceeding buffer

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mbufio/memstream.ha | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/bufio/memstream.ha b/bufio/memstream.ha @@ -57,6 +57,9 @@ export fn fixed(in: []u8, mode: io::mode) memstream = { }; fn fixed_write(s: *io::stream, buf: const []u8) (size | io::error) = { + if (len(buf) == 0) { + return 0z; + }; let s = s: *memstream; if (s.pos >= len(s.buf)) { abort("bufio::fixed buffer exceeded"); @@ -268,4 +271,6 @@ fn copy(dest: *io::stream, src: *io::stream) (io::error | size) = { let sink = fixed(out, io::mode::WRITE); io::copy(&sink, &source)!; assert(bytes::equal(in, out)); + + assert(io::write(&sink, [])! == 0); };