]> granicus.if.org Git - python/commitdiff
Issue #19437: Fix pysqlite_cursor_iternext() of sqlite3, when the row factory
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 5 Nov 2013 13:50:30 +0000 (14:50 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 5 Nov 2013 13:50:30 +0000 (14:50 +0100)
fails, don't consume the row (restore it) and fail immediatly (don't call
pysqlite_step())

Modules/_sqlite/cursor.c

index cf7f9d3242889a2b6e99a50de8ac74db43729c12..8d10890eb02230183da0d4c62140ff0814a0b3c4 100644 (file)
@@ -871,10 +871,15 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
     }
 
     next_row_tuple = self->next_row;
+    assert(next_row_tuple != NULL);
     self->next_row = NULL;
 
     if (self->row_factory != Py_None) {
         next_row = PyObject_CallFunction(self->row_factory, "OO", self, next_row_tuple);
+        if (next_row == NULL) {
+            self->next_row = next_row_tuple;
+            return NULL;
+        }
         Py_DECREF(next_row_tuple);
     } else {
         next_row = next_row_tuple;