diff options
author | Gerhard Häring <gh@ghaering.de> | 2008-04-06 11:05:24 +0000 |
---|---|---|
committer | Gerhard Häring <gh@ghaering.de> | 2008-04-06 11:05:24 +0000 |
commit | 3d7326138144598c5d52b87fe0d28371682d2c65 (patch) | |
tree | 8355e895253ee6fb81608c10ee539475d9713d78 /Modules | |
parent | 872bb2312462fa51fd851e1fc8beffed1a1a56f8 (diff) | |
download | cpython-3d7326138144598c5d52b87fe0d28371682d2c65.tar.gz |
Fix for Issue2515: Don't crash when trying to fetch data from a closed cursor.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/cursor.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 91d8f74eef..ed5e652ebb 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; |