diff -up rpm-4.8.0/python/header-py.c.header-refcount rpm-4.8.0/python/header-py.c --- rpm-4.8.0/python/header-py.c.header-refcount 2009-12-09 15:37:32.000000000 +0200 +++ rpm-4.8.0/python/header-py.c 2018-03-21 13:55:17.294541869 +0200 @@ -370,6 +370,7 @@ static PyObject *hdr_new(PyTypeObject *s h = headerNew(); } else if (PyCObject_Check(obj)) { h = PyCObject_AsVoidPtr(obj); + headerLink(h); } else if (hdrObject_Check(obj)) { h = headerCopy(((hdrObject*) obj)->h); } else if (PyBytes_Check(obj)) { @@ -692,8 +693,7 @@ PyObject * hdr_Wrap(PyTypeObject *subtyp { hdrObject * hdr = (hdrObject *)subtype->tp_alloc(subtype, 0); if (hdr == NULL) return NULL; - - hdr->h = headerLink(h); + hdr->h = h; return (PyObject *) hdr; } diff -up rpm-4.8.0/python/rpmmi-py.c.header-refcount rpm-4.8.0/python/rpmmi-py.c --- rpm-4.8.0/python/rpmmi-py.c.header-refcount 2018-03-21 13:55:00.353541049 +0200 +++ rpm-4.8.0/python/rpmmi-py.c 2018-03-21 13:55:00.524541057 +0200 @@ -1,6 +1,7 @@ #include "rpmsystem-py.h" #include +#include #include "rpmmi-py.h" #include "header-py.h" @@ -76,6 +77,7 @@ rpmmi_iternext(rpmmiObject * s) s->mi = rpmdbFreeIterator(s->mi); return NULL; } + headerLink(h); return hdr_Wrap(&hdr_Type, h); } diff -up rpm-4.8.0/python/rpmts-py.c.header-refcount rpm-4.8.0/python/rpmts-py.c --- rpm-4.8.0/python/rpmts-py.c.header-refcount 2009-12-17 11:06:03.000000000 +0200 +++ rpm-4.8.0/python/rpmts-py.c 2018-03-21 13:55:00.524541057 +0200 @@ -355,7 +355,6 @@ rpmts_HdrFromFdno(rpmtsObject * s, PyObj if (rpmrc == RPMRC_OK) { ho = hdr_Wrap(&hdr_Type, h); - h = headerFree(h); /* ref held by python object */ } else { Py_INCREF(Py_None); ho = Py_None;