diff options
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r-- | Modules/_sqlite/cursor.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 0852aa94026..f8fe11ed1ea 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -567,11 +567,13 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation } if (!multiple) { - Py_DECREF(self->lastrowid); Py_BEGIN_ALLOW_THREADS lastrowid = sqlite3_last_insert_rowid(self->connection->db); Py_END_ALLOW_THREADS - self->lastrowid = PyLong_FromLongLong(lastrowid); + Py_SETREF(self->lastrowid, PyLong_FromLongLong(lastrowid)); + if (self->lastrowid == NULL) { + goto error; + } } if (rc == SQLITE_ROW) { @@ -842,8 +844,11 @@ pysqlite_cursor_fetchmany_impl(pysqlite_Cursor *self, int maxrows) } while ((row = pysqlite_cursor_iternext(self))) { - PyList_Append(list, row); - Py_XDECREF(row); + if (PyList_Append(list, row) < 0) { + Py_DECREF(row); + break; + } + Py_DECREF(row); if (++counter == maxrows) { break; @@ -877,8 +882,11 @@ pysqlite_cursor_fetchall_impl(pysqlite_Cursor *self) } while ((row = pysqlite_cursor_iternext(self))) { - PyList_Append(list, row); - Py_XDECREF(row); + if (PyList_Append(list, row) < 0) { + Py_DECREF(row); + break; + } + Py_DECREF(row); } if (PyErr_Occurred()) { |