Mercurial > cpython-lru_cache-weakref
diff Modules/_sqlite/connection.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 | 091df4c08d99 |
line wrap: on
line diff
--- a/Modules/_sqlite/connection.c Sun Jul 13 21:43:52 2008 +0000 +++ b/Modules/_sqlite/connection.c Sun Jul 13 21:47:59 2008 +0000 @@ -1014,19 +1014,16 @@ _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 @@ 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 @@ 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 @@ 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:
