summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/cextension
diff options
context:
space:
mode:
authorTaavi Burns <taavi.burns@gmail.com>2010-11-19 17:44:39 -0500
committerTaavi Burns <taavi.burns@gmail.com>2010-11-19 17:44:39 -0500
commitf19d7e5b972e60c843acb3389e8ae07eb6043818 (patch)
tree05c6827df0297423636e436433aed8ca3e54fd7e /lib/sqlalchemy/cextension
parente15fa0342d2ac83414c563abd8fd478251d4d35f (diff)
downloadsqlalchemy-f19d7e5b972e60c843acb3389e8ae07eb6043818.tar.gz
Fix memory leaks in the cprocessors DecimalResultProcessor, including tests. [ticket:1978]
Diffstat (limited to 'lib/sqlalchemy/cextension')
-rw-r--r--lib/sqlalchemy/cextension/processors.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/cextension/processors.c b/lib/sqlalchemy/cextension/processors.c
index 327462fa8..193fb19f3 100644
--- a/lib/sqlalchemy/cextension/processors.c
+++ b/lib/sqlalchemy/cextension/processors.c
@@ -289,6 +289,7 @@ DecimalResultProcessor_process(DecimalResultProcessor *self, PyObject *value)
return NULL;
str = PyString_Format(self->format, args);
+ Py_DECREF(args);
if (str == NULL)
return NULL;
@@ -300,6 +301,14 @@ DecimalResultProcessor_process(DecimalResultProcessor *self, PyObject *value)
}
}
+static void
+DecimalResultProcessor_dealloc(DecimalResultProcessor *self)
+{
+ Py_XDECREF(self->type);
+ Py_XDECREF(self->format);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
static PyMethodDef DecimalResultProcessor_methods[] = {
{"process", (PyCFunction)DecimalResultProcessor_process, METH_O,
"The value processor itself."},
@@ -312,7 +321,7 @@ static PyTypeObject DecimalResultProcessorType = {
"sqlalchemy.DecimalResultProcessor", /* tp_name */
sizeof(DecimalResultProcessor), /* tp_basicsize */
0, /* tp_itemsize */
- 0, /* tp_dealloc */
+ (destructor)DecimalResultProcessor_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */