Fix number of references on spec_Type (#1426578)
This commit is contained in:
parent
cef3bf8220
commit
b50c8542c2
79
rpm-4.13.x-fix-refcount-for-spec_type.patch
Normal file
79
rpm-4.13.x-fix-refcount-for-spec_type.patch
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
From aaf691dbc85295aeb09e1ea4081089a24dc28759 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
|
||||||
|
Date: Tue, 21 Feb 2017 11:37:20 +0100
|
||||||
|
Subject: [PATCH] Fix number of references on spec_Type (#114)
|
||||||
|
|
||||||
|
After creating a specPkg from a spec file we must increase spec file reference counter. Otherwise spec file may be accidentally deallocated and usage of SpecPkg can cause an error.
|
||||||
|
---
|
||||||
|
python/spec-py.c | 14 +++++++++++---
|
||||||
|
python/spec-py.h | 2 +-
|
||||||
|
2 files changed, 12 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/python/spec-py.c b/python/spec-py.c
|
||||||
|
index f710f5c..753afba 100644
|
||||||
|
--- a/python/spec-py.c
|
||||||
|
+++ b/python/spec-py.c
|
||||||
|
@@ -45,8 +45,14 @@ struct specPkgObject_s {
|
||||||
|
PyObject_HEAD
|
||||||
|
/*type specific fields */
|
||||||
|
rpmSpecPkg pkg;
|
||||||
|
+ specObject *source_spec;
|
||||||
|
};
|
||||||
|
|
||||||
|
+static void specPkg_dealloc(specPkgObject * s)
|
||||||
|
+{
|
||||||
|
+ Py_DECREF(s->source_spec);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static PyObject *pkgGetSection(rpmSpecPkg pkg, int section)
|
||||||
|
{
|
||||||
|
char *sect = rpmSpecPkgGetSection(pkg, section);
|
||||||
|
@@ -95,7 +101,7 @@ PyTypeObject specPkg_Type = {
|
||||||
|
"rpm.specpkg", /* tp_name */
|
||||||
|
sizeof(specPkgObject), /* tp_size */
|
||||||
|
0, /* tp_itemsize */
|
||||||
|
- 0, /* tp_dealloc */
|
||||||
|
+ (destructor) specPkg_dealloc, /* tp_dealloc */
|
||||||
|
0, /* tp_print */
|
||||||
|
0, /* tp_getattr */
|
||||||
|
0, /* tp_setattr */
|
||||||
|
@@ -227,7 +233,7 @@ static PyObject * spec_get_packages(specObject *s, void *closure)
|
||||||
|
iter = rpmSpecPkgIterInit(s->spec);
|
||||||
|
|
||||||
|
while ((pkg = rpmSpecPkgIterNext(iter)) != NULL) {
|
||||||
|
- PyObject *po = specPkg_Wrap(&specPkg_Type, pkg);
|
||||||
|
+ PyObject *po = specPkg_Wrap(&specPkg_Type, pkg, s);
|
||||||
|
if (!po) {
|
||||||
|
rpmSpecPkgIterFree(iter);
|
||||||
|
Py_DECREF(pkgList);
|
||||||
|
@@ -350,12 +356,14 @@ spec_Wrap(PyTypeObject *subtype, rpmSpec spec)
|
||||||
|
return (PyObject *) s;
|
||||||
|
}
|
||||||
|
|
||||||
|
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
|
||||||
|
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source)
|
||||||
|
{
|
||||||
|
specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
|
||||||
|
if (s == NULL) return NULL;
|
||||||
|
|
||||||
|
s->pkg = pkg;
|
||||||
|
+ s->source_spec = source;
|
||||||
|
+ Py_INCREF(s->source_spec);
|
||||||
|
return (PyObject *) s;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/python/spec-py.h b/python/spec-py.h
|
||||||
|
index 558fbf2..65b8dc3 100644
|
||||||
|
--- a/python/spec-py.h
|
||||||
|
+++ b/python/spec-py.h
|
||||||
|
@@ -13,6 +13,6 @@ extern PyTypeObject specPkg_Type;
|
||||||
|
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type)
|
||||||
|
|
||||||
|
PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
|
||||||
|
-PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg);
|
||||||
|
+PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg, specObject *source);
|
||||||
|
|
||||||
|
#endif /* RPMPYTHON_SPEC */
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
6
rpm.spec
6
rpm.spec
@ -29,7 +29,7 @@
|
|||||||
Summary: The RPM package management system
|
Summary: The RPM package management system
|
||||||
Name: rpm
|
Name: rpm
|
||||||
Version: %{rpmver}
|
Version: %{rpmver}
|
||||||
Release: %{?snapver:0.%{snapver}.}2%{?dist}
|
Release: %{?snapver:0.%{snapver}.}3%{?dist}
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
Url: http://www.rpm.org/
|
Url: http://www.rpm.org/
|
||||||
Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
|
Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
|
||||||
@ -64,6 +64,7 @@ Patch140: rpm-4.13.x-brp-python-bytecompile-Python3-only.patch
|
|||||||
# Upstream PR: https://github.com/rpm-software-management/rpm/pull/154
|
# Upstream PR: https://github.com/rpm-software-management/rpm/pull/154
|
||||||
# rhbz#1421776
|
# rhbz#1421776
|
||||||
Patch141: rpm-4.13.x-pythondistdeps.py-fix-processing-wheels.patch
|
Patch141: rpm-4.13.x-pythondistdeps.py-fix-processing-wheels.patch
|
||||||
|
Patch142: rpm-4.13.x-fix-refcount-for-spec_type.patch
|
||||||
|
|
||||||
# Fedora-specific (python3) patch (RHBZ #1405483)
|
# Fedora-specific (python3) patch (RHBZ #1405483)
|
||||||
Patch200: rpm-4.13.x-pythondistdeps-python3.patch
|
Patch200: rpm-4.13.x-pythondistdeps-python3.patch
|
||||||
@ -569,6 +570,9 @@ exit 0
|
|||||||
%doc doc/librpm/html/*
|
%doc doc/librpm/html/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Feb 24 2017 Pavlina Moravcova Varekova <pmoravco@redhat.com> - 4.13.0.2-3
|
||||||
|
- Fix number of references on spec_Type (#1426578)
|
||||||
|
|
||||||
* Thu Feb 16 2017 Tomas Orsava <torsava@redhat.com> - 4.13.0.1-2
|
* Thu Feb 16 2017 Tomas Orsava <torsava@redhat.com> - 4.13.0.1-2
|
||||||
- Fix handling of Python wheels by pythondistdeps.py --provides (#1421776)
|
- Fix handling of Python wheels by pythondistdeps.py --provides (#1421776)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user