Issue #3153: sqlite leaks on error.

Changed statements of the form Py_DECREF(obj), obj = 0 to Py_CLEAR(obj).
This commit is contained in:
Alexandre Vassalotti 2008-07-13 21:47:59 +00:00
parent b93dc5f0ce
commit bd70476897
2 changed files with 12 additions and 23 deletions

View file

@ -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);