diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-06-07 21:51:59 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-06-07 21:51:59 +0300 |
commit | 48048a39309e180fa439b1b158a87c2081bafbaa (patch) | |
tree | d36f229882a2f01151dee05a0eacfcf996815250 /python/rpmmi-py.c | |
parent | 578e90f2f83ba1872890182902f0fd0de28db402 (diff) | |
download | librpm-tizen-48048a39309e180fa439b1b158a87c2081bafbaa.tar.gz librpm-tizen-48048a39309e180fa439b1b158a87c2081bafbaa.tar.bz2 librpm-tizen-48048a39309e180fa439b1b158a87c2081bafbaa.zip |
Ts/db reference counting for match-iterators in python (rhbz#241751)
Adds additional refcounting to the python level ts/db object to avoid
anonymous ts/db from getting deleted while still iterating over it.
Diffstat (limited to 'python/rpmmi-py.c')
-rw-r--r-- | python/rpmmi-py.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index d6ca7cedc..537804421 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -199,6 +199,7 @@ static void rpmmi_dealloc(/*@only@*/ /*@null@*/ rpmmiObject * s) { if (s) { s->mi = rpmdbFreeIterator(s->mi); + Py_DECREF(s->ref); PyObject_Del(s); } } @@ -271,7 +272,7 @@ PyTypeObject rpmmi_Type = { }; /*@=fullinitblock@*/ -rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi) +rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi, PyObject *s) { rpmmiObject * mio = (rpmmiObject *) PyObject_New(rpmmiObject, &rpmmi_Type); @@ -280,6 +281,8 @@ rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi) return NULL; } mio->mi = mi; + mio->ref = s; + Py_INCREF(mio->ref); return mio; } |