From: Alexander Kanavin <a...@linutronix.de> Signed-off-by: Alexander Kanavin <a...@linutronix.de> --- ...n-iterator-of-a-ConfigParser-section.patch | 76 +++++++++++++++++++ meta/recipes-devtools/libdnf/libdnf_0.73.4.bb | 1 + 2 files changed, 77 insertions(+) create mode 100644 meta/recipes-devtools/libdnf/libdnf/0001-Fix-a-segfault-in-iterator-of-a-ConfigParser-section.patch
diff --git a/meta/recipes-devtools/libdnf/libdnf/0001-Fix-a-segfault-in-iterator-of-a-ConfigParser-section.patch b/meta/recipes-devtools/libdnf/libdnf/0001-Fix-a-segfault-in-iterator-of-a-ConfigParser-section.patch new file mode 100644 index 00000000000..64334e08fda --- /dev/null +++ b/meta/recipes-devtools/libdnf/libdnf/0001-Fix-a-segfault-in-iterator-of-a-ConfigParser-section.patch @@ -0,0 +1,76 @@ +From 18e69ca69a6a401922275d1e18bbaf96b84ca795 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <m...@hroncok.cz> +Date: Fri, 6 Dec 2024 18:01:16 +0100 +Subject: [PATCH] Fix a segfault in iterator of a ConfigParser section + +An iterator should return self on __iter__. + +So that this works: + + >>> it1 = iter(sectObj) + >>> it2 = iter(it1) + >>> it1 is it2 + True + +Previously, this iterator did not return self on __iter__, it was like this: + + class PreserveOrderMapStringStringIterator(object): + ... + def __iter__(self): + return _common_types.PreserveOrderMapStringStringIterator___iter__(self) + +And that returned a new Python object. + +This fixes https://bugzilla.redhat.com/2330562 by avoiding a second iterator object. + +My SWIG skills are close to zero, +perhaps this is not the best way to return self, but it seems to work. + +Upstream-Status: Backport [https://github.com/rpm-software-management/libdnf/commit/f3302a865b230e021e9defbcea978ed1290a9b2f] +Signed-off-by: Alexander Kanavin <a...@linutronix.de> +--- + bindings/swig/common_types.i | 11 +++++++---- + bindings/swig/conf.i | 4 ---- + 2 files changed, 7 insertions(+), 8 deletions(-) + +diff --git a/bindings/swig/common_types.i b/bindings/swig/common_types.i +index c9ae798a..a1f90d9e 100644 +--- a/bindings/swig/common_types.i ++++ b/bindings/swig/common_types.i +@@ -63,10 +63,6 @@ template<class T> + class Iterator { + public: + Iterator(typename T::iterator _cur, typename T::iterator _end) : cur(_cur), end(_end) {} +- Iterator* __iter__() +- { +- return this; +- } + + typename T::iterator cur; + typename T::iterator end; +@@ -165,3 +161,10 @@ EXTEND_TEMPLATE_PreserveOrderMapIterator(std::string, std::string) + EXTEND_TEMPLATE_PreserveOrderMapIterator(std::string, libdnf::PreserveOrderMap<std::string, std::string>) + + %exception; // beware this resets all exception handlers if you import this file after defining any ++ ++%pythoncode %{ ++def PreserveOrderMapStringStringIterator___iter__(self): ++ return self ++PreserveOrderMapStringStringIterator.__iter__ = PreserveOrderMapStringStringIterator___iter__ ++del PreserveOrderMapStringStringIterator___iter__ ++%} +diff --git a/bindings/swig/conf.i b/bindings/swig/conf.i +index b6a0ce88..2f77003f 100644 +--- a/bindings/swig/conf.i ++++ b/bindings/swig/conf.i +@@ -71,10 +71,6 @@ template<class T> + class Iterator { + public: + Iterator(typename T::iterator _cur, typename T::iterator _end) : cur(_cur), end(_end) {} +- Iterator* __iter__() +- { +- return this; +- } + + typename T::iterator cur; + typename T::iterator end; diff --git a/meta/recipes-devtools/libdnf/libdnf_0.73.4.bb b/meta/recipes-devtools/libdnf/libdnf_0.73.4.bb index 0817da7ca69..5b9e734e82d 100644 --- a/meta/recipes-devtools/libdnf/libdnf_0.73.4.bb +++ b/meta/recipes-devtools/libdnf/libdnf_0.73.4.bb @@ -11,6 +11,7 @@ SRC_URI = "git://github.com/rpm-software-management/libdnf;branch=dnf-4-master;p file://enable_test_data_dir_set.patch \ file://0001-drop-FindPythonInstDir.cmake.patch \ file://armarch.patch \ + file://0001-Fix-a-segfault-in-iterator-of-a-ConfigParser-section.patch \ " SRCREV = "79ed383cd5a822e6d8d9d549835383f5c5106204" -- 2.39.5
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#209338): https://lists.openembedded.org/g/openembedded-core/message/209338 Mute This Topic: https://lists.openembedded.org/mt/110404197/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-