Skip to content

Commit a713df6

Browse files
Special case read with length zero
1 parent c7a00c2 commit a713df6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Modules/_sqlite/blob.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static PyObject *
139139
read_multiple(pysqlite_Blob *self, Py_ssize_t length, Py_ssize_t offset)
140140
{
141141
assert(length <= sqlite3_blob_bytes(self->blob));
142-
assert(offset <= sqlite3_blob_bytes(self->blob));
142+
assert(offset < sqlite3_blob_bytes(self->blob));
143143

144144
PyObject *buffer = PyBytes_FromStringAndSize(NULL, length);
145145
if (buffer == NULL) {
@@ -191,6 +191,11 @@ blob_read_impl(pysqlite_Blob *self, int length)
191191
length = max_read_len;
192192
}
193193

194+
assert(length >= 0);
195+
if (length == 0) {
196+
return PyBytes_FromStringAndSize(NULL, 0);
197+
}
198+
194199
PyObject *buffer = read_multiple(self, length, self->offset);
195200
if (buffer == NULL) {
196201
return NULL;

0 commit comments

Comments
 (0)