aboutsummaryrefslogtreecommitdiff
path: root/core/bytes/reader.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-08-27 18:45:13 -0400
committerLaytan <laytanlaats@hotmail.com>2024-08-28 19:53:20 +0200
commitf453054affd7b85f8c751c4f62b21788ae9d8ceb (patch)
tree5e1196be43da94a4e5a329c53d951bf6daad7479 /core/bytes/reader.odin
parentef99373c31bf515d9e5ab0b2749fb04771311c71 (diff)
Return `0, nil` in all `io` cases where an empty slice is provided
Diffstat (limited to 'core/bytes/reader.odin')
-rw-r--r--core/bytes/reader.odin6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/bytes/reader.odin b/core/bytes/reader.odin
index d85e4fe13..2e1c5ed42 100644
--- a/core/bytes/reader.odin
+++ b/core/bytes/reader.odin
@@ -34,6 +34,9 @@ reader_size :: proc(r: ^Reader) -> i64 {
}
reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
if r.i >= i64(len(r.s)) {
return 0, .EOF
}
@@ -43,6 +46,9 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) {
return
}
reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Error) {
+ if len(p) == 0 {
+ return 0, nil
+ }
if off < 0 {
return 0, .Invalid_Offset
}