From: Gerhard Häring Date: Sun, 6 Apr 2008 11:05:24 +0000 (+0000) Subject: Fix for Issue2515: Don't crash when trying to fetch data from a closed cursor. X-Git-Tag: v2.5.3c1~112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a269762fb0223fc6b7dae675f16bea48cddfdb32;p=thirdparty%2FPython%2Fcpython.git Fix for Issue2515: Don't crash when trying to fetch data from a closed cursor. --- diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 91d8f74eef4a..ed5e652ebb04 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -851,15 +851,17 @@ PyObject* cursor_iternext(Cursor *self) next_row = next_row_tuple; } - rc = _sqlite_step_with_busyhandler(self->statement->st, self->connection); - if (rc != SQLITE_DONE && rc != SQLITE_ROW) { - Py_DECREF(next_row); - _seterror(self->connection->db); - return NULL; - } + if (self->statement) { + rc = _sqlite_step_with_busyhandler(self->statement->st, self->connection); + if (rc != SQLITE_DONE && rc != SQLITE_ROW) { + Py_DECREF(next_row); + _seterror(self->connection->db); + return NULL; + } - if (rc == SQLITE_ROW) { - self->next_row = _fetch_one_row(self); + if (rc == SQLITE_ROW) { + self->next_row = _fetch_one_row(self); + } } return next_row;