diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-12-09 14:42:03 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-12-09 14:44:18 +0200 |
commit | 60b66dc7d9c728d6b779d3d772ac36b9134a2f56 (patch) | |
tree | 5dc1bcdf48a05e142687bc4f72c9b5a431aac802 /python | |
parent | a250601a8e7b31cba2565cfaf82dbfc3f6be7338 (diff) | |
download | librpm-tizen-60b66dc7d9c728d6b779d3d772ac36b9134a2f56.tar.gz librpm-tizen-60b66dc7d9c728d6b779d3d772ac36b9134a2f56.tar.bz2 librpm-tizen-60b66dc7d9c728d6b779d3d772ac36b9134a2f56.zip |
Fix a few list-related memleaks in python bindings
- PyList_Append() bumps the object reference count, callers need to
explicitly decref them... oops :)
Diffstat (limited to 'python')
-rw-r--r-- | python/header-py.c | 4 | ||||
-rw-r--r-- | python/rpmtd-py.c | 4 | ||||
-rw-r--r-- | python/rpmts-py.c | 1 | ||||
-rw-r--r-- | python/spec-py.c | 2 |
4 files changed, 9 insertions, 2 deletions
diff --git a/python/header-py.c b/python/header-py.c index 041605852..539db0dbe 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -139,7 +139,9 @@ static PyObject * hdrKeyList(hdrObject * s) rpmTag tag; while ((tag = headerNextTag(hi)) != RPMTAG_NOT_FOUND) { - PyList_Append(keys, PyInt_FromLong(tag)); + PyObject *to = PyInt_FromLong(tag); + PyList_Append(keys, to); + Py_DECREF(to); } headerFreeIterator(hi); diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c index eef35fe7b..1ba3a3d51 100644 --- a/python/rpmtd-py.c +++ b/python/rpmtd-py.c @@ -46,7 +46,9 @@ PyObject *rpmtd_AsPyobj(rpmtd td) if (array) { res = PyList_New(0); while (rpmtdNext(td) >= 0) { - PyList_Append(res, rpmtd_ItemAsPyobj(td, class)); + PyObject *item = rpmtd_ItemAsPyobj(td, class); + PyList_Append(res, item); + Py_DECREF(item); } } else { res = rpmtd_ItemAsPyobj(td, class); diff --git a/python/rpmts-py.c b/python/rpmts-py.c index f7748186a..c948d22c8 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -518,6 +518,7 @@ rpmts_Problems(rpmtsObject * s) while (rpmpsNextIterator(psi) >= 0) { PyObject *prob = rpmprob_Wrap(&rpmProblem_Type, rpmpsGetProblem(psi)); PyList_Append(problems, prob); + Py_DECREF(prob); } rpmpsFreeIterator(psi); rpmpsFree(ps); diff --git a/python/spec-py.c b/python/spec-py.c index e162bb362..f5a4b3330 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -177,6 +177,7 @@ static PyObject * spec_get_sources(specObject *s, void *closure) PyObject *srcUrl = Py_BuildValue("(sii)", source->fullSource, source->num, source->flags); PyList_Append(sourceList, srcUrl); + Py_DECREF(srcUrl); } return sourceList; @@ -192,6 +193,7 @@ static PyObject * spec_get_packages(specObject *s, void *closure) for (pkg = spec->packages; pkg; pkg = pkg->next) { PyObject *po = specPkg_Wrap(&specPkg_Type, pkg); PyList_Append(pkgList, po); + Py_DECREF(po); } return pkgList; } |