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/connection.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/connection.c')
-rw-r--r-- | Modules/_sqlite/connection.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 8269e0b..2071c33 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1014,19 +1014,16 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py _pysqlite_seterror(self->db, NULL); } - Py_DECREF(statement); - statement = 0; + Py_CLEAR(statement); } else { weakref = PyWeakref_NewRef((PyObject*)statement, NULL); if (!weakref) { - Py_DECREF(statement); - statement = 0; + Py_CLEAR(statement); goto error; } if (PyList_Append(self->statements, weakref) != 0) { - Py_DECREF(weakref); - statement = 0; + Py_CLEAR(weakref); goto error; } @@ -1050,15 +1047,13 @@ PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args, method = PyObject_GetAttrString(cursor, "execute"); if (!method) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); goto error; } result = PyObject_CallObject(method, args); if (!result) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); } error: @@ -1081,15 +1076,13 @@ PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* a method = PyObject_GetAttrString(cursor, "executemany"); if (!method) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); goto error; } result = PyObject_CallObject(method, args); if (!result) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); } error: @@ -1112,15 +1105,13 @@ PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject* method = PyObject_GetAttrString(cursor, "executescript"); if (!method) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); goto error; } result = PyObject_CallObject(method, args); if (!result) { - Py_DECREF(cursor); - cursor = 0; + Py_CLEAR(cursor); } error: |