summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-12 13:04:49 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-12 13:04:49 +0200
commit4eb6bf32792b37d97f7d0d50bf2669b04fa77583 (patch)
tree999d45b9df98cf68871704d3f513e39b139d91d7
parentebdbc02bfd5d43246bf837527dd659a435b8bfde (diff)
downloadpython-apt-4eb6bf32792b37d97f7d0d50bf2669b04fa77583.tar.gz
python/sourcelist.cc: Fix deletion of MetaIndex objects returned in SourceList.list.
First of all, make the objects mortal by decreasing their refcount after adding them to the list. Secondly, make the objects owned by SourceList and thirdly, set NoDelete on them, because they are managed by SourceList.
-rw-r--r--python/sourcelist.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 0820d5bf..aceb19ad 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -90,9 +90,12 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*)
for (vector<metaIndex *>::const_iterator I = list->begin();
I != list->end(); I++)
{
- PyObject *Obj;
- Obj = CppPyObject_NEW<metaIndex*>(&MetaIndexType,*I);
+ CppOwnedPyObject<metaIndex*> *Obj;
+ Obj = CppOwnedPyObject_NEW<metaIndex*>(Self, &MetaIndexType,*I);
+ // Never delete metaIndex*, they are managed by the pkgSourceList.
+ Obj->NoDelete = true;
PyList_Append(List,Obj);
+ Py_DECREF(Obj);
}
return List;
}