File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/Microsoft.Data.Sqlite.Core Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,12 @@ public virtual int Read(Span<byte> buffer)
206206 count = ( int ) ( Length - position ) ;
207207 }
208208
209- var rc = sqlite3_blob_read ( _blob , buffer . Slice ( 0 , count ) , ( int ) position ) ;
210- SqliteException . ThrowExceptionForRC ( rc , _connection . Handle ) ;
209+ // Newer sqlite3_blob_read returns error for 0-byte reads.
210+ if ( count > 0 )
211+ {
212+ var rc = sqlite3_blob_read ( _blob , buffer . Slice ( 0 , count ) , ( int ) position ) ;
213+ SqliteException . ThrowExceptionForRC ( rc , _connection . Handle ) ;
214+ }
211215 _position += count ;
212216 return count ;
213217 }
@@ -280,8 +284,12 @@ public virtual void Write(ReadOnlySpan<byte> buffer)
280284 throw new NotSupportedException ( Resources . ResizeNotSupported ) ;
281285 }
282286
283- var rc = sqlite3_blob_write ( _blob , buffer . Slice ( 0 , count ) , ( int ) position ) ;
284- SqliteException . ThrowExceptionForRC ( rc , _connection . Handle ) ;
287+ // Newer sqlite3_blob_write returns error for 0-byte writes.
288+ if ( count > 0 )
289+ {
290+ var rc = sqlite3_blob_write ( _blob , buffer . Slice ( 0 , count ) , ( int ) position ) ;
291+ SqliteException . ThrowExceptionForRC ( rc , _connection . Handle ) ;
292+ }
285293 _position += count ;
286294 }
287295
You can’t perform that action at this time.
0 commit comments