From c6a2f7f3f293c0947ea015cea40618c78fc93de9 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 18 Nov 2009 11:33:57 +0200 Subject: [PATCH] Fix rpmProblem reference counting in python bindings --- python/rpmps-py.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/rpmps-py.c b/python/rpmps-py.c index ee47619e2..404020bf8 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -66,13 +66,19 @@ static PyObject *rpmprob_str(rpmProblemObject *s) return res; } +static PyObject *rpmprob_dealloc(rpmProblemObject *s) +{ + s->prob = rpmProblemFree(s->prob); + Py_TYPE(s)->tp_free((PyObject *)s); +} + PyTypeObject rpmProblem_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "rpm.prob", /* tp_name */ sizeof(rpmProblemObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)0, /* tp_dealloc */ + (destructor)rpmprob_dealloc, /* tp_dealloc */ 0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ @@ -115,7 +121,7 @@ PyObject *rpmprob_Wrap(PyTypeObject *subtype, rpmProblem prob) rpmProblemObject * s = (rpmProblemObject *)subtype->tp_alloc(subtype, 0); if (s == NULL) return NULL; - s->prob = prob; + s->prob = rpmProblemLink(prob); return (PyObject *) s; }