Return 0, nil in all io cases where an empty slice is provided

This commit is contained in:
Feoramund
2024-08-28 19:53:20 +02:00
committed by Laytan
parent ef99373c31
commit f453054aff
6 changed files with 44 additions and 1 deletions
+9
View File
@@ -340,6 +340,9 @@ _limited_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte,
l := (^Limited_Reader)(stream_data)
#partial switch mode {
case .Read:
if len(p) == 0 {
return 0, nil
}
if l.n <= 0 {
return 0, .EOF
}
@@ -394,6 +397,9 @@ _section_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte,
s := (^Section_Reader)(stream_data)
#partial switch mode {
case .Read:
if len(p) == 0 {
return 0, nil
}
if s.off >= s.limit {
return 0, .EOF
}
@@ -405,6 +411,9 @@ _section_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte,
s.off += i64(n)
return
case .Read_At:
if len(p) == 0 {
return 0, nil
}
p, off := p, offset
if off < 0 || off >= s.limit - s.base {