From 3ff993b7bcbb74f7ba4a2e2a5ff2fce207c39961 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 21 Mar 2013 16:26:27 +0100 Subject: 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 --- src/libs/installer/fileutils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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()); -- cgit v1.2.3