[Python-checkins] r62183 - python/branches/release25-maint/Modules/_sqlite/cursor.c

gerhard.haering python-checkins at python.org
Sun Apr 6 13:05:24 CEST 2008


Author: gerhard.haering
Date: Sun Apr  6 13:05:24 2008
New Revision: 62183

Modified:
   python/branches/release25-maint/Modules/_sqlite/cursor.c
Log:
Fix for Issue2515: Don't crash when trying to fetch data from a closed cursor.


Modified: python/branches/release25-maint/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/release25-maint/Modules/_sqlite/cursor.c	(original)
+++ python/branches/release25-maint/Modules/_sqlite/cursor.c	Sun Apr  6 13:05:24 2008
@@ -851,15 +851,17 @@
         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;


More information about the Python-checkins mailing list