From d610c18ce6791c2e595155c8a095eaf7aa5996a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=9C=A8?= Date: Thu, 16 May 2024 18:22:55 +0800 Subject: [PATCH] Fix memory leak detected in get_best_solution() method (cherry picked from commit 651579b02ef00a167bcc111ad1760f55c1c8794f) --- backport-subject-py-Fix-memory-leak.patch | 29 +++++++++++++++++++++++ libdnf.spec | 9 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 backport-subject-py-Fix-memory-leak.patch diff --git a/backport-subject-py-Fix-memory-leak.patch b/backport-subject-py-Fix-memory-leak.patch new file mode 100644 index 0000000..d85da8d --- /dev/null +++ b/backport-subject-py-Fix-memory-leak.patch @@ -0,0 +1,29 @@ +From fd284bda6f7430b2e939f95c6836c972e22a2eb4 Mon Sep 17 00:00:00 2001 +From: Marek Blaha +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 + diff --git a/libdnf.spec b/libdnf.spec index c4a4684..4d12edf 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -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 - 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 - 0.70.2-2 - Type:bugfix - CVE:NA -- Gitee