Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85a12a8

Browse files
committed
Issue #19437: Fix pysqlite_cursor_iternext() of sqlite3, when the row factory
fails, don't consume the row (restore it) and fail immediatly (don't call pysqlite_step())
1 parent b3e1ef1 commit 85a12a8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Modules/_sqlite/cursor.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,15 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
871871
}
872872

873873
next_row_tuple = self->next_row;
874+
assert(next_row_tuple != NULL);
874875
self->next_row = NULL;
875876

876877
if (self->row_factory != Py_None) {
877878
next_row = PyObject_CallFunction(self->row_factory, "OO", self, next_row_tuple);
879+
if (next_row == NULL) {
880+
self->next_row = next_row_tuple;
881+
return NULL;
882+
}
878883
Py_DECREF(next_row_tuple);
879884
} else {
880885
next_row = next_row_tuple;

0 commit comments

Comments
 (0)