diff Modules/_sqlite/cursor.c @ 47951:afe8d515bfe2 legacy-trunk

Issue #3153: sqlite leaks on error. Changed statements of the form Py_DECREF(obj), obj = 0 to Py_CLEAR(obj).
author Alexandre Vassalotti <alexandre@peadrop.com>
date Sun, 13 Jul 2008 21:47:59 +0000
parents 52294af4b663
children 4c77d1016f60
line wrap: on
line diff
--- a/Modules/_sqlite/cursor.c	Sun Jul 13 21:43:52 2008 +0000
+++ b/Modules/_sqlite/cursor.c	Sun Jul 13 21:47:59 2008 +0000
@@ -545,7 +545,7 @@
         }
         rc = pysqlite_statement_create(self->statement, self->connection, operation);
         if (rc != SQLITE_OK) {
-            self->statement = 0;
+            Py_CLEAR(self->statement);
             goto error;
         }
     }
@@ -681,8 +681,7 @@
             self->next_row = _pysqlite_fetch_one_row(self);
         } else if (rc == SQLITE_DONE && !multiple) {
             pysqlite_statement_reset(self->statement);
-            Py_DECREF(self->statement);
-            self->statement = 0;
+            Py_CLEAR(self->statement);
         }
 
         switch (statement_type) {
@@ -988,8 +987,7 @@
 
     if (self->statement) {
         (void)pysqlite_statement_reset(self->statement);
-        Py_DECREF(self->statement);
-        self->statement = 0;
+        Py_CLEAR(self->statement);
     }
 
     Py_INCREF(Py_None);