|
Igor Gnatenko |
082d5d |
From 6e748a4eb167b2ca201d9e90b927cc4523eabeda Mon Sep 17 00:00:00 2001
|
|
Pavlina Moravcova Varekova |
b50c85 |
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
|
|
Igor Gnatenko |
082d5d |
Date: Tue, 21 Feb 2017 11:48:27 +0100
|
|
Igor Gnatenko |
082d5d |
Subject: [PATCH 03/49] Fix number of references on spec_Type (#114)
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Igor Gnatenko |
082d5d |
After creating a specPkg from a spec file we must increase spec file
|
|
Igor Gnatenko |
082d5d |
reference counter. Otherwise spec file may be accidentally deallocated
|
|
Igor Gnatenko |
082d5d |
and usage of SpecPkg can cause an error.
|
|
Igor Gnatenko |
082d5d |
|
|
Igor Gnatenko |
082d5d |
(cherry picked from commit 34b61a1f82f6f9b675ab4ca820b6255af63680f1)
|
|
Pavlina Moravcova Varekova |
b50c85 |
---
|
|
Pavlina Moravcova Varekova |
b50c85 |
python/spec-py.c | 14 +++++++++++---
|
|
Pavlina Moravcova Varekova |
b50c85 |
python/spec-py.h | 2 +-
|
|
Pavlina Moravcova Varekova |
b50c85 |
2 files changed, 12 insertions(+), 4 deletions(-)
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
diff --git a/python/spec-py.c b/python/spec-py.c
|
|
Igor Gnatenko |
082d5d |
index f710f5c87..753afbad4 100644
|
|
Pavlina Moravcova Varekova |
b50c85 |
--- a/python/spec-py.c
|
|
Pavlina Moravcova Varekova |
b50c85 |
+++ b/python/spec-py.c
|
|
Pavlina Moravcova Varekova |
b50c85 |
@@ -45,8 +45,14 @@ struct specPkgObject_s {
|
|
Pavlina Moravcova Varekova |
b50c85 |
PyObject_HEAD
|
|
Pavlina Moravcova Varekova |
b50c85 |
/*type specific fields */
|
|
Pavlina Moravcova Varekova |
b50c85 |
rpmSpecPkg pkg;
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ specObject *source_spec;
|
|
Pavlina Moravcova Varekova |
b50c85 |
};
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
+static void specPkg_dealloc(specPkgObject * s)
|
|
Pavlina Moravcova Varekova |
b50c85 |
+{
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ Py_DECREF(s->source_spec);
|
|
Pavlina Moravcova Varekova |
b50c85 |
+}
|
|
Pavlina Moravcova Varekova |
b50c85 |
+
|
|
Pavlina Moravcova Varekova |
b50c85 |
static PyObject *pkgGetSection(rpmSpecPkg pkg, int section)
|
|
Pavlina Moravcova Varekova |
b50c85 |
{
|
|
Pavlina Moravcova Varekova |
b50c85 |
char *sect = rpmSpecPkgGetSection(pkg, section);
|
|
Pavlina Moravcova Varekova |
b50c85 |
@@ -95,7 +101,7 @@ PyTypeObject specPkg_Type = {
|
|
Pavlina Moravcova Varekova |
b50c85 |
"rpm.specpkg", /* tp_name */
|
|
Pavlina Moravcova Varekova |
b50c85 |
sizeof(specPkgObject), /* tp_size */
|
|
Pavlina Moravcova Varekova |
b50c85 |
0, /* tp_itemsize */
|
|
Pavlina Moravcova Varekova |
b50c85 |
- 0, /* tp_dealloc */
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ (destructor) specPkg_dealloc, /* tp_dealloc */
|
|
Pavlina Moravcova Varekova |
b50c85 |
0, /* tp_print */
|
|
Pavlina Moravcova Varekova |
b50c85 |
0, /* tp_getattr */
|
|
Pavlina Moravcova Varekova |
b50c85 |
0, /* tp_setattr */
|
|
Pavlina Moravcova Varekova |
b50c85 |
@@ -227,7 +233,7 @@ static PyObject * spec_get_packages(specObject *s, void *closure)
|
|
Pavlina Moravcova Varekova |
b50c85 |
iter = rpmSpecPkgIterInit(s->spec);
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) {
|
|
Pavlina Moravcova Varekova |
b50c85 |
- PyObject *po = specPkg_Wrap(&specPkg_Type, pkg);
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ PyObject *po = specPkg_Wrap(&specPkg_Type, pkg, s);
|
|
Pavlina Moravcova Varekova |
b50c85 |
if (!po) {
|
|
Pavlina Moravcova Varekova |
b50c85 |
rpmSpecPkgIterFree(iter);
|
|
Pavlina Moravcova Varekova |
b50c85 |
Py_DECREF(pkgList);
|
|
Pavlina Moravcova Varekova |
b50c85 |
@@ -350,12 +356,14 @@ spec_Wrap(PyTypeObject *subtype, rpmSpec spec)
|
|
Pavlina Moravcova Varekova |
b50c85 |
return (PyObject *) s;
|
|
Pavlina Moravcova Varekova |
b50c85 |
}
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
|
|
Pavlina Moravcova Varekova |
b50c85 |
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source)
|
|
Pavlina Moravcova Varekova |
b50c85 |
{
|
|
Pavlina Moravcova Varekova |
b50c85 |
specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
|
|
Pavlina Moravcova Varekova |
b50c85 |
if (s == NULL) return NULL;
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
s->pkg = pkg;
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ s->source_spec = source;
|
|
Pavlina Moravcova Varekova |
b50c85 |
+ Py_INCREF(s->source_spec);
|
|
Pavlina Moravcova Varekova |
b50c85 |
return (PyObject *) s;
|
|
Pavlina Moravcova Varekova |
b50c85 |
}
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
diff --git a/python/spec-py.h b/python/spec-py.h
|
|
Igor Gnatenko |
082d5d |
index 558fbf207..65b8dc3d7 100644
|
|
Pavlina Moravcova Varekova |
b50c85 |
--- a/python/spec-py.h
|
|
Pavlina Moravcova Varekova |
b50c85 |
+++ b/python/spec-py.h
|
|
Pavlina Moravcova Varekova |
b50c85 |
@@ -13,6 +13,6 @@ extern PyTypeObject specPkg_Type;
|
|
Pavlina Moravcova Varekova |
b50c85 |
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type)
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
|
|
Pavlina Moravcova Varekova |
b50c85 |
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg);
|
|
Pavlina Moravcova Varekova |
b50c85 |
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source);
|
|
Pavlina Moravcova Varekova |
b50c85 |
|
|
Pavlina Moravcova Varekova |
b50c85 |
#endif /* RPMPYTHON_SPEC */
|
|
Pavlina Moravcova Varekova |
b50c85 |
--
|
|
Igor Gnatenko |
082d5d |
2.13.2
|
|
Pavlina Moravcova Varekova |
b50c85 |
|