Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/fill
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-12-18 19:45:57 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-12-19 18:35:21 (GMT)
commit75854b56f534ddcf3f5418e5a747f699c11c3944 (patch)
treea7f5206c427f8a0cf3dc0b380724d66873efc56e /fill
parentf88201e7622c14bcaaea0426ddc3cb730509acf2 (diff)
Fix memory leak in flood_fill method - SL #4334
Important information about refcounting in python [1] and [2] Te binaries for different architectures need be recompiled. [1] http://docs.python.org/release/2.5.2/api/refcountDetails.html [2] http://edcjones.tripod.com/refcount.html Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'fill')
-rw-r--r--fill/fillmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fill/fillmodule.c b/fill/fillmodule.c
index e9b461c..6e4823c 100644
--- a/fill/fillmodule.c
+++ b/fill/fillmodule.c
@@ -71,6 +71,7 @@ static PyObject* fill(PyObject* self, PyObject* args)
item = PySequence_GetItem(mylist, index);
/* assign to the C array */
intarr[index] = PyLong_AsUnsignedLong(item);
+ Py_DECREF(item);
}
/* now use intarr and arrsize in you extension */
@@ -81,8 +82,8 @@ static PyObject* fill(PyObject* self, PyObject* args)
for (index = 0; index < arrsize; index++) {
PyTuple_SetItem(pylist, index, PyLong_FromUnsignedLong(intarr[index]));
}
-
- return Py_BuildValue("O", pylist);
+ free(intarr);
+ return pylist;
}