From: Christian Kamm Date: Mon, 18 Feb 2019 13:32:47 +0000 (+0100) Subject: Folder wizard: Fix infinite loop for bad paths #7041 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~286 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=83268c255aecefd6791a6d1fc3cb2e5616012343;p=nextcloud-desktop.git Folder wizard: Fix infinite loop for bad paths #7041 --- 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(); }