From 83268c255aecefd6791a6d1fc3cb2e5616012343 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 18 Feb 2019 14:32:47 +0100 Subject: [PATCH] Folder wizard: Fix infinite loop for bad paths #7041 --- src/gui/folderman.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index b690a86d4..3991ca4b4 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1479,7 +1479,16 @@ static QString canonicalPath(const QString &path) { QFileInfo selFile(path); if (!selFile.exists()) { - return canonicalPath(selFile.dir().path()) + '/' + selFile.fileName(); + const auto parentPath = selFile.dir().path(); + + // It's possible for the parentPath to match the path + // (possibly we've arrived at a non-existant drive root on Windows) + // and recursing would be fatal. + if (parentPath == path) { + return path; + } + + return canonicalPath(parentPath) + '/' + selFile.fileName(); } return selFile.canonicalFilePath(); } -- 2.30.2