commit:     061a895f7b0a310b374dff03af622b11146337d4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 25 10:14:18 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Feb 25 10:18:02 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=061a895f

iter_parents: prevent infinite loop after empty os.path.dirname result

Reported-by: dkjii <AT> cock.li
Bug: https://bugs.gentoo.org/772806
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/util/path.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/portage/util/path.py b/lib/portage/util/path.py
index a0b96c7f3..f174bd71f 100644
--- a/lib/portage/util/path.py
+++ b/lib/portage/util/path.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
@@ -45,4 +45,6 @@ def iter_parents(path):
        yield path
        while path != os.sep:
                path = os.path.dirname(path)
+               if not path:
+                       break
                yield path

Reply via email to