diff --git a/faststreams/output_stream.nim b/faststreams/output_stream.nim index a3193fb..5fd8dae 100644 --- a/faststreams/output_stream.nim +++ b/faststreams/output_stream.nim @@ -356,6 +356,7 @@ proc append*(c: var WriteCursor, bytes: openarray[byte]) {.inline.} = pageRemaining = c.runway inputLen = bytes.len + if inputLen == 0: return if inputLen <= pageRemaining: copyMem(c.head, unsafeAddr bytes[0], inputLen) c.head = shift(c.head, inputLen) diff --git a/tests/test_output_stream.nim b/tests/test_output_stream.nim index 26f02f1..90f17a2 100644 --- a/tests/test_output_stream.nim +++ b/tests/test_output_stream.nim @@ -55,6 +55,10 @@ suite "output stream": test "no appends produce an empty output": checkOutputsMatch() + test "append zero length slice": + output "" + checkOutputsMatch() + test "string output": for i in 0 .. 1: output $i