diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-10 16:18:52 -0800 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-10 16:18:52 -0800 |
| commit | 5448f6129cd0487c3d06324385cc2ef0701b5815 (patch) | |
| tree | cdc8bd5a7312e37dc8fb873c7211be49e54b202c /lib/sqlalchemy/cextension | |
| parent | db69a48231754c4279b2ceb5ce7317a50ed839d2 (diff) | |
| download | sqlalchemy-5448f6129cd0487c3d06324385cc2ef0701b5815.tar.gz | |
- [bug] Fixed memory leak in core which would
occur when C extensions were used with
particular types of result fetches,
in particular when orm query.count()
were called. [ticket:2427]
Diffstat (limited to 'lib/sqlalchemy/cextension')
| -rw-r--r-- | lib/sqlalchemy/cextension/resultproxy.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 64b6855fa..325007c11 100644 --- a/lib/sqlalchemy/cextension/resultproxy.c +++ b/lib/sqlalchemy/cextension/resultproxy.c @@ -246,6 +246,7 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key) PyObject *exc_module, *exception; char *cstr_key; long index; + int key_fallback = 0; if (PyInt_CheckExact(key)) { index = PyInt_AS_LONG(key); @@ -276,12 +277,17 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key) "O", key); if (record == NULL) return NULL; + key_fallback = 1; } indexobject = PyTuple_GetItem(record, 2); if (indexobject == NULL) return NULL; + if (key_fallback) { + Py_DECREF(record); + } + if (indexobject == Py_None) { exc_module = PyImport_ImportModule("sqlalchemy.exc"); if (exc_module == NULL) |
