|
Panu Matilainen |
d06308 |
commit 59807943af5c10c892b239f11b8fafb209254a4a
|
|
Panu Matilainen |
d06308 |
Author: David Malcolm <dmalcolm@redhat.com>
|
|
Panu Matilainen |
d06308 |
Date: Thu Dec 15 22:22:56 2011 -0500
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
fix memory leaks in invocations of PyObject_Call
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
- Various functions in the Python bindings have expressions of the form:
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
PyObject_Call(callable,
|
|
Panu Matilainen |
d06308 |
Py_BuildValue(fmtstring, ...), NULL);
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
This leaks memory for the case when Py_BuildValue succeeds (it returns a
|
|
Panu Matilainen |
d06308 |
new reference, which is never freed; PyObject_Call doesn't steal the
|
|
Panu Matilainen |
d06308 |
reference): the argument tuple and all of its components will not be
|
|
Panu Matilainen |
d06308 |
freed (until the process exits).
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
diff --git a/python/header-py.c b/python/header-py.c
|
|
Panu Matilainen |
d06308 |
index 96cf200..cef457b 100644
|
|
Panu Matilainen |
d06308 |
--- a/python/header-py.c
|
|
Panu Matilainen |
d06308 |
+++ b/python/header-py.c
|
|
Panu Matilainen |
d06308 |
@@ -295,8 +295,7 @@ static PyObject * hdrWrite(hdrObject *s, PyObject *args, PyObject *kwds)
|
|
Panu Matilainen |
d06308 |
*/
|
|
Panu Matilainen |
d06308 |
static PyObject * hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwds)
|
|
Panu Matilainen |
d06308 |
{
|
|
Panu Matilainen |
d06308 |
- return PyObject_Call((PyObject *) &rpmfi_Type,
|
|
Panu Matilainen |
d06308 |
- Py_BuildValue("(O)", s), NULL);
|
|
Panu Matilainen |
d06308 |
+ return PyObject_CallFunctionObjArgs((PyObject *) &rpmfi_Type, s, NULL);
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
/* Backwards compatibility. Flags argument is just a dummy and discarded. */
|
|
Panu Matilainen |
d06308 |
@@ -309,14 +308,14 @@ static PyObject * hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwd
|
|
Panu Matilainen |
d06308 |
tagNumFromPyObject, &tag, &flags))
|
|
Panu Matilainen |
d06308 |
return NULL;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
- return PyObject_Call((PyObject *) &rpmds_Type,
|
|
Panu Matilainen |
d06308 |
- Py_BuildValue("(Oi)", s, tag), NULL);
|
|
Panu Matilainen |
d06308 |
+ return PyObject_CallFunction((PyObject *) &rpmds_Type,
|
|
Panu Matilainen |
d06308 |
+ "(Oi)", s, tag);
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
static PyObject * hdr_dsOfHeader(PyObject * s)
|
|
Panu Matilainen |
d06308 |
{
|
|
Panu Matilainen |
d06308 |
- return PyObject_Call((PyObject *) &rpmds_Type,
|
|
Panu Matilainen |
d06308 |
- Py_BuildValue("(Oi)", s, RPMTAG_NEVR), NULL);
|
|
Panu Matilainen |
d06308 |
+ return PyObject_CallFunction((PyObject *) &rpmds_Type,
|
|
Panu Matilainen |
d06308 |
+ "(Oi)", s, RPMTAG_NEVR);
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
static long hdr_hash(PyObject * h)
|
|
Panu Matilainen |
d06308 |
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c
|
|
Panu Matilainen |
d06308 |
index 89a70cd..1150aa1 100644
|
|
Panu Matilainen |
d06308 |
--- a/python/rpmfd-py.c
|
|
Panu Matilainen |
d06308 |
+++ b/python/rpmfd-py.c
|
|
Panu Matilainen |
d06308 |
@@ -23,8 +23,8 @@ int rpmfdFromPyObject(PyObject *obj, rpmfdObject **fdop)
|
|
Panu Matilainen |
d06308 |
Py_INCREF(obj);
|
|
Panu Matilainen |
d06308 |
fdo = (rpmfdObject *) obj;
|
|
Panu Matilainen |
d06308 |
} else {
|
|
Panu Matilainen |
d06308 |
- fdo = (rpmfdObject *) PyObject_Call((PyObject *)&rpmfd_Type,
|
|
Panu Matilainen |
d06308 |
- Py_BuildValue("(O)", obj), NULL);
|
|
Panu Matilainen |
d06308 |
+ fdo = (rpmfdObject *) PyObject_CallFunctionObjArgs((PyObject *)&rpmfd_Type,
|
|
Panu Matilainen |
d06308 |
+ obj, NULL);
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
if (fdo == NULL) return 0;
|
|
Panu Matilainen |
d06308 |
|