git » pytipc » commit aa13a02

Fix memory leaks

author Alberto Bertogli
2008-02-19 00:11:45 UTC
committer Alberto Bertogli
2008-02-19 00:14:56 UTC
parent b823c3a2d7e0c295465d5fc5591a45764c71eca2

Fix memory leaks

There were memory leaks in accept() and recvfrom(), caused by a misuse of
Py_BuildValue().

We used it with 'O', which caused the reference count of the object to be
wrongfully increased, so they were never freed by the garbage collector.

tipc_ll.c +2 -2

diff --git a/tipc_ll.c b/tipc_ll.c
index 6712d77..0ef1751 100644
--- a/tipc_ll.c
+++ b/tipc_ll.c
@@ -172,7 +172,7 @@ static PyObject *tipc_accept(PyObject *self, PyObject *args)
 
 	if (newfd < 0)
 		return PyErr_SetFromErrno(PyExc_IOError);
-	return Py_BuildValue("iO", newfd, sa_to_tuple(&sa));
+	return Py_BuildValue("iN", newfd, sa_to_tuple(&sa));
 }
 
 
@@ -229,7 +229,7 @@ static PyObject *tipc_recvfrom(PyObject *self, PyObject *args)
 	str = PyString_FromStringAndSize(buf, rv);
 	free(buf);
 
-	return Py_BuildValue("OO", str, sa_to_tuple(&sa));
+	return Py_BuildValue("NN", str, sa_to_tuple(&sa));
 }
 
 static PyObject *tipc_build_subscr(PyObject *self, PyObject *args)