Skip to content

Commit 7d10860

Browse files
committed
Blob I/O: add extra checks after review
1 parent cb853d0 commit 7d10860

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

blob_io.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ func (s *SQLiteBlob) Read(b []byte) (n int, err error) {
6868
return 0, io.EOF
6969
}
7070

71+
if len(b) == 0 {
72+
return 0, nil
73+
}
74+
7175
n = s.size - s.offset
7276
if len(b) < n {
7377
n = len(b)
@@ -86,6 +90,10 @@ func (s *SQLiteBlob) Read(b []byte) (n int, err error) {
8690

8791
// Write implements the io.Writer interface.
8892
func (s *SQLiteBlob) Write(b []byte) (n int, err error) {
93+
if len(b) == 0 {
94+
return 0, nil
95+
}
96+
8997
if s.offset >= s.size {
9098
return 0, fmt.Errorf("sqlite3.SQLiteBlob.Write: insufficient space in %d-byte blob", s.size)
9199
}

0 commit comments

Comments
 (0)