diff options
author | Tim Jenssen <tim.jenssen@digia.com> | 2013-03-21 16:26:27 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@digia.com> | 2013-03-21 16:48:45 +0100 |
commit | 3ff993b7bcbb74f7ba4a2e2a5ff2fce207c39961 (patch) | |
tree | 8727df7596f1913080974bffeafc83ca7cb3d2b3 /src | |
parent | bb5d8be66eb1ccd15b87369d9668ab342587a828 (diff) |
fix possible loop in moveDirectoryContents method
If the user wants to move the content of a directory
in a subdirectory, it shouldn't copy itself.
Change-Id: I5d5d1b8bdb315b8122fb77ada779d46a63cd2277
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/fileutils.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 315a34f5d..be08aa8ad 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -393,8 +393,11 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString & while (it.hasNext()) { const QFileInfo i(it.next()); if (i.isDir()) { - moveDirectoryContents(QDir(sourceDir).absoluteFilePath(i.fileName()), - QDir(targetDir).absoluteFilePath(i.fileName())); + // only copy directories that are not the target to avoid loop dir creations + QString newSource = QDir(sourceDir).absoluteFilePath(i.fileName()); + if (QDir(newSource) != QDir(targetDir)) { + moveDirectoryContents(newSource, QDir(targetDir).absoluteFilePath(i.fileName())); + } } else { QFile f(i.filePath()); const QString target = QDir(targetDir).absoluteFilePath(i.fileName()); |