Compare commits

...

3 Commits

Author SHA1 Message Date
Petr Písař d74820743d Fix destructing libdnf::TransactionItem from a base class
Resolves: RHEL-26240
2024-04-18 13:05:19 +02:00
Petr Písař 8b5fc624b3 Fix a memory leak in get_best_solution()
Resolves: RHEL-26226
2024-04-18 11:51:33 +02:00
Petr Písař dec77ba440 Grow memory if applying a query after increasing a number of available packages
Resolves: RHEL-27657
2024-04-18 10:57:57 +02:00
4 changed files with 125 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 3c5641a9c7c416e387a54eaf7dad7c33db52b0ec Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Wed, 6 Mar 2024 07:46:34 +0100
Subject: [PATCH] Replace assert by map_grow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: ef8ac7fcedea1ec87dd3149ce1abdf8daeee25b9
It will make code prepared for situation when number of solvables
is increased after query is created and applied.
The issue can be easilly triggered by adding remote RPMs therefore
the patch fixes a standard situation
Resolves: https://issues.redhat.com/browse/RHEL-27657
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
libdnf/sack/query.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libdnf/sack/query.cpp b/libdnf/sack/query.cpp
index 79377703..6eecfa50 100644
--- a/libdnf/sack/query.cpp
+++ b/libdnf/sack/query.cpp
@@ -2313,7 +2313,7 @@ Query::Impl::apply()
if (!result)
initResult();
map_init(&m, pool->nsolvables);
- assert(m.size == result->getMap()->size);
+ map_grow(result->getMap(), pool->nsolvables);
for (auto f : filters) {
map_empty(&m);
switch (f.getKeyname()) {
--
2.44.0

View File

@ -0,0 +1,37 @@
From c91ed331cc9ea6512a7aaad918db1be9bc6d4f69 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Tue, 26 Mar 2024 14:09:47 +0100
Subject: [PATCH] subject-py: Fix memory leak
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: fd284bda6f7430b2e939f95c6836c972e22a2eb4
Posible memory leak was detected in get_best_solution() method.
Resolves: https://issues.redhat.com/browse/RHEL-26226
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
python/hawkey/subject-py.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/python/hawkey/subject-py.cpp b/python/hawkey/subject-py.cpp
index a88d572a..3e1919e7 100644
--- a/python/hawkey/subject-py.cpp
+++ b/python/hawkey/subject-py.cpp
@@ -361,8 +361,10 @@ get_best_solution(_SubjectObject *self, PyObject *args, PyObject *kwds)
HyNevra nevra{nullptr};
UniquePtrPyObject q(get_solution(self, args, kwds, &nevra));
- if (!q)
+ if (!q) {
+ delete nevra;
return NULL;
+ }
PyObject *ret_dict = PyDict_New();
PyDict_SetItem(ret_dict, PyString_FromString("query"), q.get());
if (nevra) {
--
2.44.0

View File

@ -0,0 +1,40 @@
From 74150bafa1ffb8527e8eef7507da50562bcb9983 Mon Sep 17 00:00:00 2001
From: Nicola Sella <nsella@redhat.com>
Date: Tue, 26 Mar 2024 14:35:43 +0100
Subject: [PATCH] Add virtual destructor to TransactionItem
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: e4e90777f789fc45e002b4c0385c0565a76be946
Resolves: https://issues.redhat.com/browse/RHEL-26240
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
libdnf/transaction/TransactionItem.hpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libdnf/transaction/TransactionItem.hpp b/libdnf/transaction/TransactionItem.hpp
index 72684f73..5addad45 100644
--- a/libdnf/transaction/TransactionItem.hpp
+++ b/libdnf/transaction/TransactionItem.hpp
@@ -43,6 +43,8 @@ namespace libdnf {
class TransactionItemBase {
public:
+ virtual ~TransactionItemBase() = default;
+
ItemPtr getItem() const noexcept { return item; }
void setItem(ItemPtr value) { item = value; }
@@ -101,6 +103,7 @@ public:
explicit TransactionItem(Transaction *trans);
TransactionItem(SQLite3Ptr conn, int64_t transID);
+ virtual ~TransactionItem() = default;
int64_t getId() const noexcept { return id; }
void setId(int64_t value) { id = value; }
--
2.44.0

View File

@ -58,7 +58,7 @@
Name: libdnf
Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version}
Release: 8%{?dist}
Release: 9%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
@ -71,6 +71,9 @@ Patch5: 0005-filterAdvisory-installed_solvables-sort-RhBug2212838.patch
Patch6: 0006-hawkeysubject-get_best_selectors-only-obsol-oflatest.patch
Patch7: 0007-Avoid-reinstal-installonly-packages-marked-for-ERASE.patch
Patch8: 0008-PGP-Set-a-default-creation-SELinux-labels-on-GnuPG-d.patch
Patch9: 0009-Replace-assert-by-map_grow.patch
Patch10: 0010-subject-py-Fix-memory-leak.patch
Patch11: 0011-Add-virtual-destructor-to-TransactionItem.patch
BuildRequires: cmake
@ -320,6 +323,12 @@ popd
%endif
%changelog
* Tue Apr 16 2024 Petr Pisar <ppisar@redhat.com> - 0.69.0-9
- Grow memory if applying a query after increasing a number of available
packages (RHEL-27657)
- Fix a memory leak in get_best_solution() (RHEL-26226)
- Fix destructing libdnf::TransactionItem from a base class (RHEL-26240)
* Wed Oct 25 2023 Petr Pisar <ppisar@redhat.com> - 0.69.0-8
- Set default SELinux labels on GnuPG directories (RHEL-11238)