public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: Fix number of references on spec_Type (#1426578)
@ 2026-11-23 9:30 Pavlina Moravcova Varekova
0 siblings, 0 replies; only message in thread
From: Pavlina Moravcova Varekova @ 2026-11-23 9:30 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : b50c8542c204f2d8950d04e5dd0b1becdefc8f0e
Author : Pavlina Moravcova Varekova <pmoravco@redhat.com>
Date : 2017-02-24T12:41:41+01:00
Stats : +84/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/b50c8542c204f2d8950d04e5dd0b1becdefc8f0e?branch=pmatilai-v6
Log:
Fix number of references on spec_Type (#1426578)
---
diff --git a/rpm-4.13.x-fix-refcount-for-spec_type.patch b/rpm-4.13.x-fix-refcount-for-spec_type.patch
new file mode 100644
index 0000000..4d8a460
--- /dev/null
+++ b/rpm-4.13.x-fix-refcount-for-spec_type.patch
@@ -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
+
diff --git a/rpm.spec b/rpm.spec
index a5a530b..8e66224 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}2%{?dist}
+Release: %{?snapver:0.%{snapver}.}3%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
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
# rhbz#1421776
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)
Patch200: rpm-4.13.x-pythondistdeps-python3.patch
@@ -569,6 +570,9 @@ exit 0
%doc doc/librpm/html/*
%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
- Fix handling of Python wheels by pythondistdeps.py --provides (#1421776)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 9:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 9:30 [rpms/rpm] pmatilai-v6: Fix number of references on spec_Type (#1426578) Pavlina Moravcova Varekova
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox