diff options
| author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-07-13 21:47:59 (GMT) |
|---|---|---|
| committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-07-13 21:47:59 (GMT) |
| commit | bd70476897a16be21d5e26394c8c367d37e2c4c6 (patch) | |
| tree | 1d73abbadace62873665a5e4ff83490637a59c19 /Modules/_sqlite/cursor.c | |
| parent | b93dc5f0cee59f1c7bfe6c3a85c834e14a708469 (diff) | |
| download | cpython-bd70476897a16be21d5e26394c8c367d37e2c4c6.zip cpython-bd70476897a16be21d5e26394c8c367d37e2c4c6.tar.gz cpython-bd70476897a16be21d5e26394c8c367d37e2c4c6.tar.bz2 | |
Issue #3153: sqlite leaks on error.
Changed statements of the form Py_DECREF(obj), obj = 0 to Py_CLEAR(obj).
Diffstat (limited to 'Modules/_sqlite/cursor.c')
| -rw-r--r-- | Modules/_sqlite/cursor.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 0d7d59a..7c0ca4b 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -545,7 +545,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* } 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 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* 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 @@ PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args) if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); - self->statement = 0; + Py_CLEAR(self->statement); } Py_INCREF(Py_None); |
