diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-07-23 12:00:41 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-07-26 09:17:24 +0200 |
commit | 5bc6d8e5802500a6ffd737185f30283bc65eba58 (patch) | |
tree | 37630166d24db9c05945c642bc75d0d19173b8b1 /src/qt/intro.cpp | |
parent | 2b894bceac90af4500403b510488d5821548cd45 (diff) |
fix possible infinite loop in intro.cpp thread
- it was possible to trigger an infinite loop in FreespaceChecker::check() by
simply removing the drive letter on Windows (which leads to an infinite
loop in the FreespaceChecker thread)
- this was caused by not checking if we make progress with
parentDir.parent_path()
Diffstat (limited to 'src/qt/intro.cpp')
-rw-r--r-- | src/qt/intro.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index 51f3c812e4..944899d3e8 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -25,6 +25,7 @@ static const uint64 BLOCK_CHAIN_SIZE = 10LL * GB_BYTES; class FreespaceChecker : public QObject { Q_OBJECT + public: FreespaceChecker(Intro *intro); @@ -61,9 +62,16 @@ void FreespaceChecker::check() /* Find first parent that exists, so that fs::space does not fail */ fs::path parentDir = dataDir; + fs::path parentDirOld = fs::path(); while(parentDir.has_parent_path() && !fs::exists(parentDir)) { parentDir = parentDir.parent_path(); + + /* Check if we make any progress, break if not to prevent an infinite loop here */ + if (parentDirOld == parentDir) + break; + + parentDirOld = parentDir; } try { @@ -201,7 +209,7 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable } else { ui->freeSpace->setStyleSheet(""); } - ui->freeSpace->setText(freeString+"."); + ui->freeSpace->setText(freeString + "."); } /* Don't allow confirm in ERROR state */ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR); |