Fix memory leak detected in get_best_solution() method

This commit is contained in:
肖在 2024-05-16 18:22:55 +08:00
parent dbdd44d32b
commit 651579b02e
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From fd284bda6f7430b2e939f95c6836c972e22a2eb4 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Tue, 26 Mar 2024 14:09:47 +0100
Subject: [PATCH 293/300] subject-py: Fix memory leak
Posible memory leak was detected in get_best_solution() method.
---
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.33.0

View File

@ -18,7 +18,7 @@
Name: libdnf
Version: 0.70.2
Release: 2
Release: 3
Summary: Library providing simplified C and Python API to libsolv
License: LGPL-2.1-or-later
URL: https://github.com/rpm-software-management/libdnf
@ -48,6 +48,7 @@ Patch6002: backport-python-bindings-Load-all-modules-with-RTLD_G
Patch6003: backport-Avoid-reinstalling-installonly-packages-marked-for-ERASE.patch
Patch6004: backport-dnf-repo-do-not-download-repository-if-our-local-cache-is-up-to-date.patch
Patch6005: backport-dnf-repo-Fix-utimes-error-messages.patch
Patch6006: backport-subject-py-Fix-memory-leak.patch
%description
A Library providing simplified C and Python API to libsolv.
@ -127,6 +128,12 @@ popd
%{python3_sitearch}/hawkey/
%changelog
* Thu May 16 2024 xiaozai <xiaozai@kylinos.cn> - 0.70.2-3
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC: Fix memory leak detected in get_best_solution() method
* Tue Jan 02 2024 chenhaixing <chenhaixing@huawei.com> - 0.70.2-2
- Type:bugfix
- CVE:NA